0

I need to replace a string "//" to the string "/". For example:

/video//5//record

I need it to be:

/video/5/record

I want to use sed:

sed -i -e 's//////g' inputfile

But I think I have some problem deal with the escape char. Any help will be greatly appreciated!!!

2 Answers 2

3

sed can use other delimiters ( any punctuation character ) Try:

     sed -i -e 's://:/:g' infile
Sign up to request clarification or add additional context in comments.

1 Comment

Can't imagine why this got downvoted - have an upvote for the right answer!
2

You can also try the below by escaping.

$ echo "/video//5//record" | sed -e 's/\/\//\//g'
/video/5/record

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.