Re: [CentOS] script help

2009-06-18 Thread Mohan
Hi If your file has only 2 columns and there is no space exists in 2nd column then you can use this script #!/bin/sh FILE=list.txt OUTPUT=out.txt while read VAL do VAL1=$(echo $VAL | awk '{print $1}' ) VAL2=$(echo $VAL | awk '{print $2}' ) echo DEAR: $VAL1 $OUPUT echo DEAR: $VAL2 $OUPUT

Re: [CentOS] script help

2009-06-18 Thread John Doe
From: chloe K chloekcy2...@yahoo.ca I have a file. list.txt (two columns) column1column2 nameaddress I need to put in the letter file letter.txt eg: Dear: Chloe Address: CA Can I use this for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt For

Re: [CentOS] script help

2009-06-18 Thread Mfawa Alfred Onen
Dear Chloe, John Doe`s script is a good start, even though it will work for single words space separated. The LINE Variable only passes the Arguments as single words to ($1 and $2 respectively). I will also work on something for you too... On Thu, Jun 18, 2009 at 10:34 AM, John Doe

[CentOS] script help

2009-06-17 Thread chloe K
Hi   I have a file. list.txt (two columns)   column1    column2 name    address     I need to put in the letter file letter.txt eg:   Dear: Chloe Address: CA   Can I use this   for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt   Thank you for your help          

Re: [CentOS] script help

2009-06-17 Thread Brian
Can I use this for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt Why don't you just try it and see if it works? ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos

Re: [CentOS] script help

2009-06-17 Thread MHR
On Wed, Jun 17, 2009 at 10:54 AM, chloe Kchloekcy2...@yahoo.ca wrote: Hi I have a file. list.txt (two columns) column1    column2 name    address I need to put in the letter file letter.txt eg: Dear: Chloe Address: CA Can I use this for i `cat list.txt` | sed 's/Chloe/$i.1;

Re: [CentOS] script help

2009-06-17 Thread MHR
On Wed, Jun 17, 2009 at 11:16 AM, Brianemailli...@beckerspace.com wrote: Can I use this for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt Why don't you just try it and see if it works? There _is_ that, but it won't :-) mhr

Re: [CentOS] script help

2009-06-17 Thread Mfawa Alfred Onen
There is going to be a problem with your sed line as the semi-column is not helping matters. You can try using a database for easy retrieval with your script. I hope it puts you on the way. On Wed, Jun 17, 2009 at 7:16 PM, Brian emailli...@beckerspace.com wrote: Can I use this for i `cat

Re: [CentOS] script help

2009-06-17 Thread Filipe Brandenburger
Hi Chloe, Please start by reading this: http://www.catb.org/~esr/faqs/smart-questions.html On Wed, Jun 17, 2009 at 13:54, chloe Kchloekcy2...@yahoo.ca wrote: I have a file. list.txt (two columns) Separated by what? Tabs? Spaces? Can the fields themselves have spaces in them? Do you have many

Re: [CentOS] script help

2009-06-17 Thread Julian Thomas
On Wed, 17 Jun 2009 11:16:58 -0700 MHR wrote: I've never seen any shell or sed syntax that allows you to subscript a line like this. You should read up on awk, although there is no simple way to do dual file processing along these lines. Easy way to do this with awk is to have the first part

Re: [CentOS] script help

2009-06-17 Thread Les Mikesell
chloe K wrote: Hi I have a file. list.txt (two columns) column1column2 nameaddress I need to put in the letter file letter.txt eg: Dear: Chloe Address: CA Can I use this for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt Thank you for your help

[CentOS] script help - '3rd last field'

2009-06-08 Thread Tom Brown
Hi I need some logic to work out a value for me - this value is _always_ the 3rd last field in a string seperated by '.' but the string could be 5 or 6 fields long, e.g foo.bar.VALUE.baz.lala foor.bar.gigi.VALUE.baz.lala I need to find VALUE - if this were python or something i could do it

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread muhammad panji
On Mon, Jun 8, 2009 at 4:29 PM, Tom Brownt...@ng23.net wrote: Hi I need some logic to work out a value for me - this value is _always_ the 3rd last field in a string seperated by '.' but the string could be 5 or 6 fields long, e.g foo.bar.VALUE.baz.lala foor.bar.gigi.VALUE.baz.lala I

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Ralph Angenendt
michael.ket...@rm-solutions.de wrote: Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel You can resubcribe then, when you are

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread James Bensley
Is there anyway you can tell which field it will be in (i.e. to use as a search clause, so search for the field with X properties?) Ultimately to get the data in the X'th field you are going to need either awk or sed (they can both easily do this, awk probably easier than sed) You need to work

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread michael . kettel
Sehr geehrte Damen und Herren, ich bin ab dem 15.06.2009 wieder zurück im Büro. Bitte wenden Sie sich in dringenden Fällen an Simon Schillings [simon.schilli...@rm-solutions.de] Viele Grüße, Michael Kettel ___ CentOS mailing list CentOS@centos.org

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Jacques B.
On Mon, Jun 8, 2009 at 5:29 AM, Tom Brownt...@ng23.net wrote: Hi I need some logic to work out a value for me - this value is _always_ the 3rd last field in a string seperated by '.' but the string could be 5 or 6 fields long, e.g foo.bar.VALUE.baz.lala foor.bar.gigi.VALUE.baz.lala I

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Alex S.
Hi. echo foo.bar.VALUE.baz.lala | awk -F. '{ print $(NF-2); }' -- Alex S.magicb...@gmail.com On 08.06.2009 13:29, Tom Brown wrote: Hi I need some logic to work out a value for me - this value is _always_ the 3rd last field in a string seperated by '.' but the string could be 5 or 6

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Tom Brown
I am pretty sure there is a way in awk to figure out how many fields you have, then take the total # of fields -3 each time to get the third last one. Just heading out the door and off hand can't remember how it would be done. i can do it in cheetah templating with set myloc =

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Mogens Kjaer
muhammad panji wrote: ... awk -F\. {'print $3'} awk -F\. {'print $5'} awk -F\. {'print $6'} awk -F\. {'print $(NF-2)'} Mogens -- Mogens Kjaer, Carlsberg A/S, Computer Department Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark Phone: +45 33 27 53 25, Mobile: +45 22 12 53 25 Email: m...@crc.dk

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Tom Brown
echo foo.bar.VALUE.baz.lala | awk -F. '{ print $(NF-2); }' excellent - just what i needed thanks ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread Stephen Harris
On Mon, Jun 08, 2009 at 10:56:09AM +0100, Tom Brown wrote: echo foo.bar.VALUE.baz.lala | awk -F. '{ print $(NF-2); }' excellent - just what i needed awk is probably the most readable way. In traditional shell stuff like this used to be done in awk or sed awk -F. '{print $(NF-2)}'

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread William L. Maltby
On Mon, 2009-06-08 at 10:29 +0100, Tom Brown wrote: Hi I need some logic to work out a value for me - this value is _always_ the 3rd last field in a string seperated by '.' but the string could be 5 or 6 fields long, e.g foo.bar.VALUE.baz.lala foor.bar.gigi.VALUE.baz.lala I need

Re: [CentOS] script help - '3rd last field'

2009-06-08 Thread William L. Maltby
On Mon, 2009-06-08 at 08:01 -0400, William L. Maltby wrote: snip 2. Inside that, use the set command to change the field separator to . snip Correction: IFS (the Interfield Separator) is just another variable. Just regular assignment will set it. -- Bill

Re: [CentOS] script help

2007-11-02 Thread Toby Bluhm
Toby Bluhm wrote: adrian kok wrote: Hi Phil thank you But I have several hundred those pattern directories! I did think to cat those directories in a file olddir eg: dir-192.168.30.0 dir-192.168.30.144 dir-192.168.30.184 and sed

Re: [CentOS] script help

2007-11-02 Thread Ross S. W. Walker
list centos@centos.org Sent: Fri Nov 02 09:28:45 2007 Subject: Re: [CentOS] script help I run it but it has error. sed 's/^dir-192\.168/dir-10\.0/'` sed: read error on dir-192.168.0.31: Is a directory --- Toby Bluhm [EMAIL PROTECTED] wrote: Toby Bluhm wrote: adrian kok wrote: Hi Phil

RE: [CentOS] script help

2007-11-02 Thread mike.redan
I run it but it has error. sed 's/^dir-192\.168/dir-10\.0/'` sed: read error on dir-192.168.0.31: Is a directory Was there an problem with Frank's response from earlier? rename 192.168 10.0 dir* It is a nice simple solution. You don't have to loop, or use extra commands, just copy

Re: [CentOS] script help

2007-11-02 Thread Michael D. Kralka
Ross S. W. Walker wrote: Try: # find parent dir -type d -name dir-192.168.\* -exec mv \{\} `echo \{\} | sed 's/192\.168\./10\.0\./'` \; That should recursively rename all directories from one naming scheme to another. ... except for the fact that the `echo \{\} ...` will be evaluated

Re: [CentOS] script help

2007-11-02 Thread adrian kok
I run it but it has error. sed 's/^dir-192\.168/dir-10\.0/'` sed: read error on dir-192.168.0.31: Is a directory --- Toby Bluhm [EMAIL PROTECTED] wrote: Toby Bluhm wrote: adrian kok wrote: Hi Phil thank you But I have several hundred those pattern directories! I did think

Re: [CentOS] script help

2007-11-02 Thread Toby Bluhm
adrian kok wrote: Hi Phil thank you But I have several hundred those pattern directories! I did think to cat those directories in a file olddir eg: dir-192.168.30.0 dir-192.168.30.144 dir-192.168.30.184 and sed 's/dir-192.168/dir-10.0/g' olddir

Re: [CentOS] script help

2007-11-01 Thread Frank Cox
On Fri, 02 Nov 2007 02:22:30 +0800 (CST) adrian kok [EMAIL PROTECTED] wrote: how can I have script to rename the following directory pattern from dir-192.168.30.0To: dir-10.0.30.0 rename 192.168 10.0 dir* -- MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com

Re: [CentOS] script help

2007-11-01 Thread James A. Peltier
adrian kok wrote: Hi all how can I have script to rename the following directory pattern from from dir-192.168.30.0 dir-192.168.30.144 dir-192.168.30.184 To: dir-10.0.30.0 dir-10.0.30.144 dir-10.0.30.184 If this is to rename individual files from

Re: [CentOS] script help

2007-11-01 Thread Phil Schaffner
On Fri, 2007-11-02 at 02:22 +0800, adrian kok wrote: Hi all how can I have script to rename the following directory pattern from from dir-192.168.30.0 dir-192.168.30.144 dir-192.168.30.184 To: dir-10.0.30.0 dir-10.0.30.144 dir-10.0.30.184 If you are just

Re: [CentOS] script help

2007-11-01 Thread adrian kok
Hi Phil thank you But I have several hundred those pattern directories! I did think to cat those directories in a file olddir eg: dir-192.168.30.0 dir-192.168.30.144 dir-192.168.30.184 and sed 's/dir-192.168/dir-10.0/g' olddir newdir but i don't

Re: [CentOS] script help

2007-11-01 Thread Frank Cox
On Fri, 02 Nov 2007 03:18:35 +0800 (CST) adrian kok [EMAIL PROTECTED] wrote: But I have several hundred those pattern directories! What's wrong with the rename command? -- MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com ___ CentOS

Re: [CentOS] script help

2007-10-26 Thread Tom Brown
How about # MOUNTER=`ssh $i mount | grep data | awk '{print \$1,\$2,\$3}'` alas no MOUNTER=`ssh $i 'mount | grep data | awk {print \$1, \$2, \$3}'` results in awk: {print , , } awk:^ syntax error awk: {print , , } awk: ^ syntax error awk: {print , , } awk:^

Re: [CentOS] script help

2007-10-26 Thread Tom Brown
How about # MOUNTER=`ssh $i mount | grep data | awk '{print \$1,\$2,\$3}'` alas no MOUNTER=`ssh $i 'mount | grep data | awk {print \$1, \$2, \$3}'` results in awk: {print , , } awk:^ syntax error awk: {print , , } awk: ^ syntax error awk: {print , , } awk:^

Re: [CentOS] script help

2007-10-26 Thread Alfred von Campe
On Oct 26, 2007, at 6:28, Tom Brown wrote: I am sure the answer here is really easy but i am stuck! Getting the quoting right for remote commands in the shell is never an easy thing :-). # mount | grep data | awk '{print$1,$2,$3}' gives me the info i require locally, however i need to

Re: [CentOS] script help

2007-10-26 Thread Anup Shukla
Tom Brown wrote: How about # MOUNTER=`ssh $i mount | grep data | awk '{print \$1,\$2,\$3}'` alas no MOUNTER=`ssh $i 'mount | grep data | awk {print \$1, \$2, \$3}'` results in awk: {print , , } awk:^ syntax error awk: {print , , } awk: ^ syntax error awk: {print , , }

Re: [CentOS] script help

2007-10-26 Thread Luciano Rocha
On Fri, Oct 26, 2007 at 11:28:37AM +0100, Tom Brown wrote: Hi I am sure the answer here is really easy but i am stuck! # mount | grep data | awk '{print$1,$2,$3}' gives me the info i require locally, however i need to execute this over about 1000 hosts so i run things remotely

Re: [CentOS] script help

2007-10-26 Thread Luciano Rocha
On Fri, Oct 26, 2007 at 11:52:50AM +0100, Luciano Rocha wrote: On Fri, Oct 26, 2007 at 11:28:37AM +0100, Tom Brown wrote: Hi I am sure the answer here is really easy but i am stuck! # mount | grep data | awk '{print$1,$2,$3}' gives me the info i require locally, however i

Re: [CentOS] script help

2007-10-26 Thread Tom Brown
Correction. MOUNTER=`ssh $i mount | grep data | awk '{print \\$1,\\$2,\\$3}'` This is what i tried and worked for me. bingo! gold star - thanks!! I need to query mount as these are nfs mounts configre by an automounter and so not in the fstab

[CentOS] script help

2007-10-26 Thread Tom Brown
Hi I am sure the answer here is really easy but i am stuck! # mount | grep data | awk '{print$1,$2,$3}' gives me the info i require locally, however i need to execute this over about 1000 hosts so i run things remotely using ssh something like # MOUNTER=`ssh $i 'mount | grep data | awk

Re: [CentOS] script help

2007-10-26 Thread Anup Shukla
Tom Brown wrote: # MOUNTER=`ssh $i 'mount | grep data | awk '{print$1,$2,$3}''` How about # MOUNTER=`ssh $i mount | grep data | awk '{print \$1,\$2,\$3}'` Regards A.S ___ CentOS mailing list CentOS@centos.org