1

I need to replace a string / line for each instance of that string / line. In the following line:

set output "/DS/tmp/2.gnuplot.ps" 

I need it to be:

set output "./gnuplot.ps" 

I want to use:

grep -rl 'stringONE' ./ | xargs sed -i 's/stringONE/stringTWO/g'

but when I try to use it, it has a conflict with the / in the string...

grep -rl '/DS/tmp/2.gnuplot.ps' ./ | xargs sed -i 's//DS/tmp/2.gnuplot.ps/./gnuplot.ps/g'

Any help will be greatly appreciated!!!

1 Answer 1

1

If the string to be replaced contains slash (/) then you can delimit arguments of sed's s command with something else, in this case I used comma:

grep -rl '/DS/tmp/2.gnuplot.ps' ./|xargs sed -i 's,/DS/tmp/2.gnuplot.ps,./gnuplot.ps,g'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.