2

I would like to replace the following sentence "lw 2,\" with the sentence "lw 2" however I cannot do it with

sed -i 's|lw 2,\|lw 2|g' "filname"

I get the following error

sed: -e expression #1, char 15: unterminated `s' command

It seems that it doesn't like the "\"

2

You just need to escape the backslash:

's|lw 2,\\|lw 2|g'
1
  • 2
    ... because the single backslash would otherwise escape the | used (for whatever reason) as a delimiter.
    – Kusalananda
    Aug 13 '19 at 9:50

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.