Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: OffTopic : sed : Alternate (2,4,6..) replacement
Will this work?
if [ $THINGY -eq 1 ]; then
B="that" THINGY=0 else THINGY=1
done
You can set up a similar loop in awk too. The sed 's/:/ /' changes the colon to a space so that the read A B JUNK will work.
> -----Original Message-----
>
> Hi List
> I need some help on this;
> How do i replace the 2nd,4th,6th occurances of a column
> (vertical) in a
> file.
> I know sed does it within a row
>
> $ cat swt
> 01:this is a file1 this
> 02:this is a file1 this
> 03:this is line3
> 04:this is line4
>
> $ sed 's/this/that/2' swt
> 01:this is a file1 that
> 02:this is a file1 that
> 03:this is line3
> 04:this is line4
> $ sed 's/this/that/1' swt
> 01:that is a file1 this
> 02:that is a file1 this
> 03:that is line3
> 04:that is line4
>
> But i want
> 01:this is a file1 this
> 02:that is a file1 this
> 03:this is line3
> 04:that is line4
>
> I tried awk but awk seems to be going one line at a time.
>
> Thanks in Advance.
>
> GovindanK
>
> --
> http://www.fastmail.fm - The professional email service
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.net
> --
> Author: GovindanK
> INET: gkatteri_at_fastmail.fm
>
> Fat City Network Services -- 858-538-5051 http://www.fatcity.com
> San Diego, California -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: <Stephen.Lee_at_DTAG.Com INET: Stephen.Lee_at_DTAG.Com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Dec 16 2003 - 10:04:31 CST