Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I just run across the following sed command:

sed "s|^/samba|\\|;s|/|\\|g"

I have seen sed substitute commands before. I also know sed allows the usage of any character as a delimeter (| in this case) and that g means global substitution.

However, I am not sure what the rest of the command does.

Perhaps more generally, how can I quickly find information on what a sed pattern like the one above does? (other than obviously reading the documentation, which is always recommended)

share|improve this question
try print -r '/nfs/x/y' | sed 's|^/nfs|\\|;s|/|\\|g' – Stéphane Chazelas Mar 28 '13 at 20:14
Thanks @StephaneChazelas That fixed it. – Amelio Vazquez-Reina Mar 28 '13 at 21:01

1 Answer 1

up vote 6 down vote accepted

That's TWO sed commands, separated by a semicolon. The first replaced /nfs at the beginning of the line with \, the second replaces any / with \ :)

share|improve this answer
Thanks! That makes sense. I just updated the OP with an error that I get – Amelio Vazquez-Reina Mar 28 '13 at 19:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.