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*

4
  • I have tried this solution but it will not work with newline(enter key) Commented Oct 4, 2017 at 22:43
  • You should perhaps use | as separator for the s command. According to a comment by the OP this is used as delimiter in the replacement file, so it seems not to be part of a replacement. Anyhow, the OP needs to add sample data. Commented Oct 5, 2017 at 8:28
  • Reserved characters means any of \&/ plus any embedded newlines(where / is the delimiter and since you cannot know what the replacement string will contain you're not gaining anything if you use another delimiter as you'll have to escape it anyway)... You are complicating things here IMO (and relying on gnu sed's z which is not mentioned in the Q)... anyay, this Q is a duplicate as it has been asked several times (and at least one of the duplicates has the right answer). Commented Oct 5, 2017 at 10:32
  • @don_crissti If this is a reply to my comment: Yes, we know that the replacement string will not contain |, so using this as delimiter will free you from caring about one of the pitfalls, while the : suggested in the answer doesn't. Commented Oct 5, 2017 at 11:08