I need to remove escape character from the string in bash. I get a data structure, which contains url paths with / escaped so I receive the regular link:
http://stackoverflow.com/questions/ask
as one with escaped /:
http:\/\/stackoverflow.com\/questions\/ask
Now I need to remove \ from the second link. For this purpose I tried using sed
 `echo '"'${paths[$index]}'"' | sed "s@\\@@g"`
But I get an error:
sed: -e expression #1, char 6: unterminated `s' command
If I replace \\ with ie. _ it works like a charm and removes all occurrences of _ in a string. How do I get rid of escape characters in a string using sed?
try this:
.......|sed 's@\\@@g'
or:
.......|sed "s@\\\\@@g"
EDIT add a test output:
kent$  echo "http:\/\/stackoverflow.com\/questions\/ask"|sed "s@\\\\@@g"
http://stackoverflow.com/questions/ask
kent$  echo "http:\/\/stackoverflow.com\/questions\/ask"|sed 's@\\@@g'  
http://stackoverflow.com/questions/ask
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With