Re: doubt in using sed
Am 2007-03-09 15:01:51, schrieb L.V.Gandhi: > I have made a script like this as test1 > #!/bin/bash > line="3IINFOTECH,2005042200,118,118,96,98.1,8260440" > olds=$(echo "$line"|cut -d, -f2) > echo $olds > da=${olds:0:8} > echo $da > echo "$line" > temp1 > sed -e 's/$olds/$da/' temp1 >>temp ^^ sed -e "s/$olds/$da/" temp1 >>temp > cat temp1 > cat temp Thanks, Greetings and nice Day Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/6192519367100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: doubt in using sed
On 3/10/07, Mathias Brodala <[EMAIL PROTECTED]> wrote: Hello. Please reply to the list. L.V.Gandhi, 10.03.2007 05:24: > In another similar one I have problem > > [EMAIL PROTECTED]:~/stock/datafiles$ ls -l nse2/ > total 0 > [EMAIL PROTECTED]:~/stock/datafiles$ ls -l 3IINFOTECH > -rw-r--r-- 1 lvgandhi lvgandhi 23400 2007-03-09 15:47 3IINFOTECH > [EMAIL PROTECTED]:~/stock/datafiles$ sed -e "s/3IINFOTECH,//" 3IINFOTECH > |less > [EMAIL PROTECTED]:~/stock/datafiles$ sed -e "s/3IINFOTECH,//" 3IINFOTECH >> /home/lvgandhi/stock/datafile/nse2/3IINFOTECH > bash: /home/lvgandhi/stock/datafile/nse2/3IINFOTECH: No such file or > directory > In sed -e "s/3IINFOTECH,//" 3IINFOTECH |less I could see the correct > output. > But when I redirect, as in next command I get error "bash: > /home/lvgandhi/stock/datafile/nse2/3IINFOTECH: No such file or directory" > Redirecting to a file in same folder works. > ie sed -e "s/3IINFOTECH,//" 3IINFOTECH > temp works. > Any explanation please You forgot a 's': 'datafiles' vs. 'datafile'. Regards, Mathias Thanks. -- L.V.Gandhi http://lvgandhi.tripod.com/ linux user No.205042
Re: doubt in using sed
On 3/9/07, David Clymer <[EMAIL PROTECTED]> wrote: On Fri, 2007-03-09 at 20:22 -0800, L.V.Gandhi wrote: > > > Thanks David and Mathias. > In the above example after double quotes it works. When I pass the > output to file it works. > In another similar one I have problem You're welcome. Please send this question to the list, and I'll take a whack at answering it. Following up off-list is lousy nettiquette. The list is your resource, not me personally. -davidc Mr.David, Sorry for personal mail. Thanks for your efforts. -- L.V.Gandhi http://lvgandhi.tripod.com/ linux user No.205042
Re: doubt in using sed
Hello. Please reply to the list. L.V.Gandhi, 10.03.2007 05:24: > In another similar one I have problem > > [EMAIL PROTECTED]:~/stock/datafiles$ ls -l nse2/ > total 0 > [EMAIL PROTECTED]:~/stock/datafiles$ ls -l 3IINFOTECH > -rw-r--r-- 1 lvgandhi lvgandhi 23400 2007-03-09 15:47 3IINFOTECH > [EMAIL PROTECTED]:~/stock/datafiles$ sed -e "s/3IINFOTECH,//" 3IINFOTECH > |less > [EMAIL PROTECTED]:~/stock/datafiles$ sed -e "s/3IINFOTECH,//" 3IINFOTECH >> /home/lvgandhi/stock/datafile/nse2/3IINFOTECH > bash: /home/lvgandhi/stock/datafile/nse2/3IINFOTECH: No such file or > directory > In sed -e "s/3IINFOTECH,//" 3IINFOTECH |less I could see the correct > output. > But when I redirect, as in next command I get error "bash: > /home/lvgandhi/stock/datafile/nse2/3IINFOTECH: No such file or directory" > Redirecting to a file in same folder works. > ie sed -e "s/3IINFOTECH,//" 3IINFOTECH > temp works. > Any explanation please You forgot a 's': 'datafiles' vs. 'datafile'. Regards, Mathias -- debian/rules signature.asc Description: OpenPGP digital signature
Re: doubt in using sed
On Fri, 2007-03-09 at 15:01 -0800, L.V.Gandhi wrote: > I have made a script like this as test1 > #!/bin/bash > line="3IINFOTECH,2005042200,118,118,96,98.1,8260440" > olds=$(echo "$line"|cut -d, -f2) > echo $olds > da=${olds:0:8} > echo $da > echo "$line" > temp1 > sed -e 's/$olds/$da/' temp1 >>temp > cat temp1 > cat temp > When I run get as > [EMAIL PROTECTED]:~/.qtstalker/data0/export$ test1 > 2005042200 > 20050422 > 3IINFOTECH,2005042200,118,118,96, 98.1,8260440 > 3IINFOTECH,2005042200,118,118,96,98.1,8260440 > I don't find any replacement. Where am I wrong? what should be done to > get the replacement done? The problem is that you've used single quotes, preventing shell expansion of your variables. Try: sed -e "s/$olds/$da/" temp1 >>temp My guess is that will work for you. -davidc -- gpg-key: http://www.zettazebra.com/files/key.gpg signature.asc Description: This is a digitally signed message part
Re: doubt in using sed
Hello. L.V.Gandhi, 10.03.2007 00:01: > I have made a script like this as test1 > #!/bin/bash > line="3IINFOTECH,2005042200,118,118,96,98.1,8260440" > olds=$(echo "$line"|cut -d, -f2) > echo $olds > da=${olds:0:8} > echo $da > echo "$line" > temp1 > sed -e 's/$olds/$da/' temp1 >>temp You want to use double quotes here so that the shell can expand the variables. Regards, Mathias -- debian/rules signature.asc Description: OpenPGP digital signature
doubt in using sed
I have made a script like this as test1 #!/bin/bash line="3IINFOTECH,2005042200,118,118,96,98.1,8260440" olds=$(echo "$line"|cut -d, -f2) echo $olds da=${olds:0:8} echo $da echo "$line" > temp1 sed -e 's/$olds/$da/' temp1 >>temp cat temp1 cat temp When I run get as [EMAIL PROTECTED]:~/.qtstalker/data0/export$ test1 2005042200 20050422 3IINFOTECH,2005042200,118,118,96,98.1,8260440 3IINFOTECH,2005042200,118,118,96,98.1,8260440 I don't find any replacement. Where am I wrong? what should be done to get the replacement done? -- L.V.Gandhi http://lvgandhi.tripod.com/ linux user No.205042