bash command

Paul Graydon paul at
Thu Oct 20 08:58:49 UTC 2011

On 10/19/2011 10:29 PM, Jesus arteche wrote:
> Hey guys,
> I want to create  a script to change some words in some sonf files at 
> the start up of the you know the command in bash for 
> search the word and replace it??
> Thanks
You're looking for 'sed'.  It's very powerful and exceptionally useful.  
In it's roughest form you can do straight text substitution:

sed -i.bkp 's/foo/bar/g'

That will replace all instances of foo with bar wherever they occur in 
the file, and leave you with a filename.bkp backup copy of the unaltered 
config (-i = in-place edit)

You can read about sed here:
If you're going to be spending time using Linux, I would strongly 
recommend taking the time to learn sed, and specifically how to form 
'Regular Expressions' (used text pattern matching).  It may take a bit 
of effort to get your head around it initially but the rewards are 
significant in what it then allows you to do.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ubuntu-server mailing list