Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.