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)

  • 1
    try print -r '/nfs/x/y' | sed 's|^/nfs|\\|;s|/|\\|g' – Stéphane Chazelas Mar 28 '13 at 20:14

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 \ :)

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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