Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have a file which is as follows and I want to delete all occurrences of the /jsn/pjs/ .270 644 /jsn/pjs/1.txt
79 17 /jsn/pjs/2.txt
I tried using as sed 's//jsn/pjs/,//g' xyz.txtBut it does not work.Can soemone please help where I am wrong?I am using KSH.
Thanks,
Poornima

You have to escape the default delimiter, /, that sed uses:
#!/bin/ksh
sed 's/\/jsn\/pjs\///g' xyz.txt
# or you can change the delimiter:
sed 's&/jsn/pjs/&&g' xyz.txt

Thanks a lot Nails. I used your second option.
Since replace was not occurring in the original file(xyz.txt), I put the output to a separate file b.txt and deleted the xyz.txt.
Thanks
Poornima

another way without too much meddling with slashes
# awk 'BEGIN{FS="/jsn/pjs/"}{$1=$1}1' file 270 644 1.txt 79 17 2.txt

![]() |
how to fetch the fileds f...
|
rsh (remsh) -l
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |