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.

3
  • 6
    The [ and ] must be escaped in both BRE and ERE (otherwise they define a range expression). As to why you get no output when escaping them and using ERE, I think it's a difference in how $ is treated between BRE and ERE when it's not the final character of a pattern - see for example Bash sed replace double dollar sign $$ extended regular expressions Commented Sep 20, 2019 at 12:29
  • 2
    sed's -E and -e options are two completely different and unrelated things. they are not alternate versions of each other. -e tells sed that the next argument is a script to be run. -E tells sed to use extended regular expressions (ERE) instead of sed's default of basic regular expressions (BRE). Commented Sep 20, 2019 at 13:02
  • You can drop the "-e", it's only if you have separate expressions. The -E option would work if you escaped the "$"'s. Commented Sep 21, 2019 at 0:24