2011/10/20 Michael DeBruyn <[email protected]> > On 10/20/2011 04:29 AM, 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 will want to use something like sed. An example: > > sed -i "s/oldword/newword/g" /some/script.sh > > This will replace all instances of oldword with newword in the file > script.sh > > If you want to do this at system boot you can put it in /etc/rc.local > > -Mike >
Note that you can also select a specific line using: sed -i "234s/oldword/newword/g" /some/script.sh to only replace "oldword" with "newword" on line 234, otherwise this would replace all occurences in the given file. See the "Addresses" section of `man sed`.
-- ubuntu-server mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-server More info: https://wiki.ubuntu.com/ServerTeam
