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*

6
  • 2
    This has the same problem as Antti's solution - if the replacement string is past a certain length, you get a "Argument list too long" error. Also, what if the replacement string has '[', ']', '*', '.', and other such characters? Would sed really not interpret those? Commented Jan 17, 2016 at 17:26
  • The replacement side of s/// is not a regular expression, it's really just a string (except for backslash-escapes and &). If the replacement string is so long, a shell one-liner is not your solution. Commented Jan 17, 2016 at 20:11
  • A very useful list if, for example, your replacement string is base64 encoded text (eg. replacing a placeholder with a SHA256 key). Then it's just the delimiter to worry about. Commented May 16, 2019 at 14:03
  • Only 4 chars special to sed? Square brackets break it too. Commented May 10, 2022 at 13:30
  • 1
    Yes. I can't remember why I did that. Possibly just to separate the "do this on every line" code from the "do this only on the last line" code. Commented Oct 25, 2022 at 18:28