0

I need to replace a string in a lot of files in a folder, with only ssh access to the server. How can I do this?

for example i want replace all files Which contains code

<script src='http://cdn.adplxmd.com/adplexmedia/tags/xbanner/xbanner.js?ap=1300' type='text/javascript'></script>

I want replace it with my name: sultan

I do something like this:

sed -i 's/<script src='http://cdn.adplxmd.com/adplexmedia/tags/xbanner/xbanner.js?ap=1300' type='text/javascript'></script>/sultan/g' *

but the problem i see error message in linux commands:

sed: -e expression #1, char 20: unknown option to `s'

How do I fix this problems?

0

1 Answer 1

1

There are two errors:

  1. the slash is used as a delimiter in your call to sed, so this ambiguity needs to be resolve
  2. you're using single quotes in the search term but also to enclose the sed parameter.

You can try something like this instead:

sed -i "s|<script src='http://cdn.adplxmd.com/adplexmedia/tags/xbanner/xbanner.js?ap=1300' type='text/javascript'></script>|sultan|g" *
Sign up to request clarification or add additional context in comments.

1 Comment

Escape the dots though.

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.