Using tr to replace newline with space

ReplaceNewlineSpaceGit BashTr

Replace Problem Overview


Have output from sed:

http://sitename.com/galleries/83450
72-profile

Those two strings should be merged into one and separated with space like:

http://sitename.com/galleries/83450 72-profile

Two strings are pipelined to tr in order to replace newline with space:

tr '\n' ' '

And it's not working, the result is the same as input.

Indicating space with ASCII code '\032' results in replacing \n with non-printable characters.

What's wrong? I'm using Git Bash on Windows.

Replace Solutions


Solution 1 - Replace

Best guess is you are on windows and your line ending settings are set for windows. See this topic: https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings

or use:

tr '\r\n' ' '

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiony.bregeyView Question on Stackoverflow
Solution 1 - ReplaceGarr GodfreyView Answer on Stackoverflow