(This simply outputs the contents of the script, unmodified)

[email protected]:~/Work/Cacti $./script | sed -e 's/$//'

Update: 經過進一步檢查，看起來每行都有一個返回字符。當使用 less 時，這顯示為 ^ M 。所以，我添加了兩個 tr 語句。一個刪除換行符，一個刪除換行符。 ./script | | tr -d '\n' | tr -d '\r'

最佳答案

sed won't work (easily) because it operates on lines one at a time; you could do it, but it would involve copying the whole input into the hold buffer tr actually should work the way you pasted it; are you sure the newlines are \ns? You can simplify it a bit by deleting the newlines instead of converting them to spaces: tr -d '\n'