Using tr to replace newline with space [duplicate]

假装没事ソ 提交于 2020-02-26 04:53:26

问题


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.


回答1:


Best guess is you are on windows and your line ending settings are set for windows. See this topic: How to change line-ending settings

or use:

tr '\r\n' ' '


来源:https://stackoverflow.com/questions/25826752/using-tr-to-replace-newline-with-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!