Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Thanks that's perfect! I will accept the answer in 8 mins when I can... can you suggest somewhere I can learn sed that's a good read? I don't want to suck with it anymore... Commented Feb 18, 2021 at 8:59
  • 1
    You say you're on Linux so you most probably use GNU sed - read its manual, it's short gnu.org/software/sed/manual. Additionally, since sed is most commonly used in shell scripts and you come across issues such as this one you should read your shell manual. Commented Feb 18, 2021 at 9:01
  • I just read that when using double quotes, your string is going to be interpreted by the shell... got it thanks again Commented Feb 18, 2021 at 9:02
  • 2
    @Woodstock I like this one: Grymoire - please note: in your original try, you escaped the parentheses \( -> Actually escaping them makes them special for grouping, while NOT escaping them just matches the character. Commented Feb 18, 2021 at 9:02
  • note that if you run that script in a file in which the subject of the regexp is alone on the line sed will replace it with an empty line. Commented Feb 27, 2021 at 23:07