1833043 Members
2688 Online
110049 Solutions
New Discussion

How to use sed?

 
SOLVED
Go to solution
lin.chen
Frequent Advisor

How to use sed?

Would you please help me to resolve this problem.

I would like to replace 'wnctce' to 'xxstitst' in file, and how could i do?

sed -e ‘s/\’wnctce\’ /\’xxstitst\’/g’< /plmap/SCRIPTS/DATA/0209/wncplm_dump0209.txt > xxstitst_dump0209.txt

this command is wrong.. How could i correct it?

thanks!!
4 REPLIES 4
lin.chen
Frequent Advisor

Re: How to use sed?

sed -e 's/\'wnctce\'/\'xxstitst\'/g'< /wncplm_dump0209.txt > xxstitst_dump0209.txt
James R. Ferguson
Acclaimed Contributor
Solution

Re: How to use sed?

Hi Lin:

Change the delimiters that bound the 'sed' program to make them differ from part of what you want to match.

Instead of:

# echo \'wnctce\'|sed -e 's/\'wnctce\'/\'xxstitst\'/g'

Use:

# echo \'wnctce\'|sed -e "s/\'wnctce\'/\'xxstitst\'/g"

...which would output:

'xxstitst'

Regards!

...JRF...
Eric SAUBIGNAC
Honored Contributor

Re: How to use sed?

Hi lin chen

do it like this :

sed -e "s/'wnctce'/'xxstitst'/g" < /wncplm_dump0209.txt > xxstitst_dump0209.txt

you will have less trouble with quote and escapes characteres

Hope this will help

Regards

Eric
Dennis Handly
Acclaimed Contributor

Re: How to use sed?

You might want to mention that you also want to change those single quotes and they weren't just meta characters in your question.