bash command
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 |
bash command
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 -- ubuntu-server mailing list ubuntu-server@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-server More info: https://wiki.ubuntu.com/ServerTeam |
bash command
On Thu, Oct 20, 2011 at 09:29:35AM BST, Jesus arteche wrote:
> 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?? You don't need bash for it, sed's your friend, e.g.: % sed -i 's/old_word/new_word/' /etc/conf.file I highly recommend. % man sed Regards, -- Raf -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org Archive: 20111020083650.GA17026@linuxstuff.pl">http://lists.debian.org/20111020083650.GA17026@linuxstuff.pl |
bash command
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 On 20/10/11 09:29, 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?? Well, I don't know about bash command but I know about sed. - -- |_|0|_| | |_|_|0| "Heghlu'Meh QaQ jajVam" | |0|0|0| -------- kuLa --------- | gpg --keyserver pgp.mit.edu --recv-keys 0xC100B4CA -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJOn923AAoJEOqHloDBALTKKWcIAL5mR6xh7l xo0OHfejjdu6o9 iX+hx0EMgJzvo89e7OacpypudyPAEnwj/hwwvEXYPQs2nABAXaGYFBjeKQlrjkeM 5X57kx127mpSMDS7hB4I1tH+L81mWwNEBowUmmAA5bzpaIt1r8 pWflrNGHKUOh/F u0VgHWhCAQ52VhQvwHA+buMm9o3wXMyrRLxUbDeYaTJWe1BvWx lbhPUOUrWBwxu8 hSeewuRdUDjmnTsbSGisUU0xWZccgQHMXnuIfVLWHVfQeJC6/dVYSmYKI58zcGvH 6QWfh7ttFZbx50btHuRWGOyHwWMtWYS9i1QKP71VMyXXGTbgBb gqt4En0uRXGVs= =XBdl -----END PGP SIGNATURE----- -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org Archive: 4E9FDDB7.9080906@kulisz.net">http://lists.debian.org/4E9FDDB7.9080906@kulisz.net |
bash command
* 2011-10-20T09:29:35+01:00 * Jesus arteche wrote:
> 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?? Sounds like you need "sed" command and its s/.../.../ command. Probably sed's --in-place option will be useful. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org Archive: 871uu8vytw.fsf@mithlond.arda">http://lists.debian.org/871uu8vytw.fsf@mithlond.arda |
bash command
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 ubuntu-server@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-server More info: https://wiki.ubuntu.com/ServerTeam |
bash command
On Thu, Oct 20, 2011 at 09:36:50AM +0100, Raf Czlonka wrote:
> On Thu, Oct 20, 2011 at 09:29:35AM BST, Jesus arteche wrote: > > 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?? > > You don't need bash for it, sed's your friend, e.g.: > > % sed -i 's/old_word/new_word/' /etc/conf.file Proving that TIMTOWTDI (or, "You don't need sed for it, bash's your friend): while read line; do echo ${line/old_word/new_word} done < /etc/conf.file > /etc/conf.file.new Sadly, this can't be done in-place, so you'll either need to use mv to replace /etc/conf.file with /etc/conf.file.new or repeat the loop (with no substitution) to copy /etc/conf.file.new into /etc/conf.file. By the way, I don't recommend this method. sed IS your friend, but bash IS capable and that's what you asked for :) -- Darac Marjal -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org Archive: 20111020105421.GB7653@darac.org.uk">http://lists.debian.org/20111020105421.GB7653@darac.org.uk |
bash command
kuLa (debian@kulisz.net on 2011-10-20 09:37 +0100):
> On 20/10/11 09:29, 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?? > > Well, I don't know about bash command but I know about sed. Theoretically it's possible with bash (>=3) as well: $ VAR=oldword $ echo $VAR oldword $ echo ${VAR/old/new} newword And use a read loop over all the lines in the file :) Regards, Arno -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org Archive: 20111020125802.1ea771b3@neminis.loos.site">http://lists.debian.org/20111020125802.1ea771b3@neminis.loos.site |
bash command
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 -- ubuntu-server mailing list ubuntu-server@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-server More info: https://wiki.ubuntu.com/ServerTeam |
bash command
2011/10/20 Michael DeBruyn <mdebruyn@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`. -- ubuntu-server mailing list ubuntu-server@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-server More info: https://wiki.ubuntu.com/ServerTeam |
| All times are GMT. The time now is 08:36 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.