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*

8
  • 128
    Sed is line-based therefore it is hard for it to grasp newlines. Commented Aug 9, 2009 at 19:22
  • 3
    Alexander: Does "stream editor" mean line-based? Perhaps, the name is confusing. Commented Aug 9, 2009 at 19:26
  • 234
    sed works on a "stream" of input, but it comprehends it in newline delimited chunks. It is a unix tool, which means it does one thing very well. The one thing is "work on a file line-wise". Making it do something else will be hard, and risks being buggy. The moral of the story is: choose the right tool. A great many of your questions seem to take the form "How can I make this tool do something it was never meant to do?" Those questions are interesting, but if they come up in the course of solving a real problem, you're probably doing it wrong. Commented Aug 9, 2009 at 19:39
  • 1
    GNU sed supports changing the "record" separator to null byte instead of newline. Commented Jan 6, 2021 at 2:37
  • 8
    tr only works with one character strings. You can't replace all new lines with a string that is multiple characters long. Commented Jan 6, 2022 at 13:45