bash command

Arnaud Soyez weboide at codealpha.net
Thu Oct 20 13:53:48 UTC 2011


2011/10/20 Michael DeBruyn <mdebruyn at flipkey.com>

>  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`.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-server/attachments/20111020/266f43f1/attachment.html>


More information about the ubuntu-server mailing list