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 system...do 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'  file.name

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: http://tldp.org/LDP/abs/html/x22860.html
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. http://www.regular-expressions.info/

Paul
-- 
ubuntu-server mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam

Reply via email to