The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-17-2008
veerapureddy veerapureddy is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
SED command ---------help needed

Hi all
I am new babie to shell script, so please advise me n help me .

suppose i have a string "abacus sabre", i need to replace occurences 'ab' with 'cd' and i need to store this result into same string and i need to return this result from script to the calling function, where as the string is passed from calling function.

i tried like this

mainStr="abacus"
old_word="ab"
new_word="cd"
result=`sed -i s/$old_word/$new_word $mainstr `
return $result