How do I use sed to remove a double backslash

Multi tool use
How do I use sed to remove a double backslash
I am trying to use sed to remove these double backslashes in the front of this string so that this:
//s3.amazonaws.com/umdheader.umd.edu/app/js/main.min.js
will become:
s3.amazonaws.com/umdheader.umd.edu/app/js/main.min.js
so far I have it where it can remove one through the com
sed 's/^///g' output
but i need to remove two! please let me know thanks :)
/
@Sash, you could use following solution too by which you need not to escape
/
to remove its special meaning stackoverflow.com/a/51139804/5866580– RavinderSingh13
Jul 2 at 15:53
/
I don't understand how you could figure out that to remove
/
you use /
but couldn't make the leap to using //
to remove //
.– Ed Morton
Jul 2 at 17:06
/
/
//
//
@MarkSetchell IMHO you don't have to be clever to figure out that if X maps to Y then XX might map to YY and give it a try! :-)
– Ed Morton
Jul 2 at 20:44
@RavinderSingh13 I upvoted to restore.
– SLePort
Jul 3 at 13:15
3 Answers
3
You can choose another delimiter than /
in your command:
/
sed 's;^//;;' file
Or, if you want to escape the /
:
/
sed 's/^////' file
Or in case you don't want to escape /
and simple want to substitute /
starting ones with NULL then do following.
/
/
echo "//s3.amazonaws.com/umdheader.umd.edu/app/js/main.min.js" | sed 's#^//##'
You can try it this way with sed:
echo "//s3.amazonaws.com/umdheader.umd.edu/app/js/main.min.js" | sed 's/^.*amazon/amazon/g'
or by regular expressions of variables
$ variable="//s3.amazonaws.com/umdheader.umd.edu/app/js/main.min.js"
$ echo ${variable#*//}
$ s3.amazonaws.com/umdheader.umd.edu/app/js/main.min.js
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
you just had to add another
/
... see also: How to use different delimiters for sed substitute command?– Sundeep
Jul 2 at 14:52