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
  • I don't see how this is different from @Fjor's answer other than you're using cat instead of reading directly from stdin. Qualifies for the useless use of cat. Also here. Commented Nov 26, 2022 at 16:32
  • The difference is just '\n' instead of '\r' Commented Dec 5, 2022 at 0:36
  • It depends only of the line endings used in the specific OS: \n is different for Windows, Linux and MacOS (I think \n is \r\l -CR,LF- in Windows, \l -LF- in Linux and \r -CR- in MacOS), so we must use the literal representation of the undesired char in tr -d to get rid of it [CR and LF are the ASCII chars Carriage Return (decimal 13) and Line Feed (decimal 10)]. Commented Apr 24, 2024 at 23:56