有 sed
的输出:
http://sitename.com/galleries/83450
72-profile
这两个字符串应该合并为一个并用空格分隔,例如:
http://sitename.com/galleries/83450 72-profile
两个字符串被管道输送到 tr
为了用空格替换换行符:
tr '\n' ' '
它不起作用,结果与输入相同。
用ASCII码'\032'
表示空格结果替换 \n
带有不可打印的字符。
怎么了?我在 Windows 上使用 Git Bash。
最佳答案
最好的猜测是您使用的是 Windows,并且您的行结束设置是针对 Windows 设置的。 请参阅此主题:How to change line-ending settings
或使用:
tr '\r\n' ' '
关于replace - 使用 tr 将换行符替换为空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25826752/