1835918 Members
2502 Online
110087 Solutions
New Discussion

shell script

 
M.Thomas
Frequent Advisor

shell script

Hi Admins,

Please tell me how to replace
/one/two/three/four/five/six to /one/two/three/work/three in shell script using SED


Thanks in advance

Regards
Thomas
3 REPLIES 3
Matti_Kurkela
Honored Contributor

Re: shell script

You can use characters other than slash as the separator in sed commands:

sed -e 's!/one/two/three/four/five/six!/one/two/three/work/three!g'

MK
MK
M.Thomas
Frequent Advisor

Re: shell script

Thanks for your help


Regards
Thomas
Yogeeraj_1
Honored Contributor

Re: shell script

hi Thomas,

Correct me if i am wrong. I dont think you want to replace ONLY one occurrance of:
/one/two/three/four/five/six

to:
/one/two/three/work/three

it would be too easy to just:

SRV2:home/yogeeraj>cat file
/one/two/three/four/five/six
SRV2:home/yogeeraj>sed "s/four/work/;s/six//;s/five/three/" file
/one/two/three/work/three/
SRV2:home/yogeeraj>




Please post more information on your source file and target destination file.

revert
kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)