使用tr用空格替换换行符

时间:2014-09-13 19:17:16

标签: replace newline space git-bash tr

拥有sed的输出:

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

这两个字符串应该合并为一个并用空格隔开,如:

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

两个字符串被流水线化为tr,以便用空格替换换行符:

tr '\n' ' '

它不起作用,结果与输入相同。

使用ASCII码'\032'指示空格会导致\n替换为不可打印的字符。

怎么了?我在Windows上使用Git Bash。

1 个答案:

答案 0 :(得分:69)

最好的猜测是你在Windows上,你的行结束设置是为windows设置的。 请参阅此主题:How to change line-ending settings

或使用:

tr '\r\n' ' '