|
|
|
|
||||||
| linux.debian.user debian-user@lists.debian.org. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have made a script like this as test1
#!/bin/bash line="3IINFOTECH,20050422000000,118,118,96,98.1,82 60440" 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 lvgandhi@lvgdell600m:~/.qtstalker/data0/export$ test1 20050422000000 20050422 3IINFOTECH,20050422000000,118,118,96,98.1,8260440 3IINFOTECH,20050422000000,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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Hello.
L.V.Gandhi, 10.03.2007 00:01: > I have made a script like this as test1 > #!/bin/bash > line="3IINFOTECH,20050422000000,118,118,96,98.1,82 60440" > 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF8enIYfUFJ3ewsJgRAp1BAKCaoWuYnrwGK/DELIA+mkfs/o3MDQCfYJKH 84eERXlwMqj/uaWoeEr4cDc= =ANWm -----END PGP SIGNATURE----- |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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,20050422000000,118,118,96,98.1,82 60440" > 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 > lvgandhi@lvgdell600m:~/.qtstalker/data0/export$ test1 > 20050422000000 > 20050422 > 3IINFOTECH,20050422000000,118,118,96, 98.1,8260440 > 3IINFOTECH,20050422000000,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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBF8euB2XpGgG+SNaERAqtEAJ4vB2Tt2Zda89IpsmLlQ9 z8el7toQCgrfpH Ac1e4jQbo35vde3iEJotcwY= =jUIM -----END PGP SIGNATURE----- |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Hello.
Please reply to the list. L.V.Gandhi, 10.03.2007 05:24: > In another similar one I have problem > > lvgandhi@lvgdell600m:~/stock/datafiles$ ls -l nse2/ > total 0 > lvgandhi@lvgdell600m:~/stock/datafiles$ ls -l 3IINFOTECH > -rw-r--r-- 1 lvgandhi lvgandhi 23400 2007-03-09 15:47 3IINFOTECH > lvgandhi@lvgdell600m:~/stock/datafiles$ sed -e "s/3IINFOTECH,//" 3IINFOTECH > |less > lvgandhi@lvgdell600m:~/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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF8pKSYfUFJ3ewsJgRApAJAJ92xpKMf+hp/Pi9rva0HY0dw9EA4wCdGP81 l0NB9kg478OWYl61UpIN0gk= =BvhP -----END PGP SIGNATURE----- |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On 3/9/07, David Clymer <david@zettazebra.com> 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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 3/10/07, Mathias Brodala <info@noctus.net> wrote:
> > Hello. > > Please reply to the list. > > L.V.Gandhi, 10.03.2007 05:24: > > In another similar one I have problem > > > > lvgandhi@lvgdell600m:~/stock/datafiles$ ls -l nse2/ > > total 0 > > lvgandhi@lvgdell600m:~/stock/datafiles$ ls -l 3IINFOTECH > > -rw-r--r-- 1 lvgandhi lvgandhi 23400 2007-03-09 15:47 3IINFOTECH > > lvgandhi@lvgdell600m:~/stock/datafiles$ sed -e "s/3IINFOTECH,//" > 3IINFOTECH > > |less > > lvgandhi@lvgdell600m:~/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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Am 2007-03-09 15:01:51, schrieb L.V.Gandhi:
> I have made a script like this as test1 > #!/bin/bash > line="3IINFOTECH,20050422000000,118,118,96,98.1,82 60440" > 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/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFGCTBoC0FPBMSS+BIRApk8AJwJb6wVAJ1qwJ5mxF4CAs/ayJsm/ACfRnfB 8zfWZ75+LC0K8+7nb4BXXT4= =9BK9 -----END PGP SIGNATURE----- |
|
![]() |
| Outils de la discussion | |
|
|