在Solaris 9上使用/ usr / xpg4 / bin / tr和/ usr / bin / tr出现exception

我有一个像这样的文件,

"xxxxxx" "yyyyyy" "aaaaaa" "cccccc" "bbbbbb" "eeeeee" "oooooo" "zzzzzz" 

想要replace这个文件中的每个\n我使用:

 tr '\n' ',' < INPUT > OUTPUT 

哪个工作正常。 输出是预期的:

 "xxxxxx","yyyyyy","aaaaaa","cccccc".... 

然而

我不能在这个文件上使用sedawk进行任何操作,但是在Linux中使用GNU软件包的时候,没有任何操作(结果总是空的,例如: sed 's/,/hello/g'什么都不显示)很好,但与非GNU不。 谁能告诉我这是为什么?

提前致谢,

安德斯

 # ls testfile.txt # /usr/xpg4/bin/tr '\n' ',' < testfile.txt "xxxxxx","yyyyyy","aaaaaa","cccccc","bbbbbb","eeeeee","oooooo","zzzzzz",,# # /usr/xpg4/bin/tr '\n' ',' < testfile.txt | sed 's/,/hello/g' # ls -l /usr/xpg4/bin/sed -r-xr-xr-x 1 root bin 27460 Apr 7 2002 /usr/xpg4/bin/sed # /usr/xpg4/bin/tr '\n' ',' < testfile.txt | /usr/xpg4/bin/sed 's/,/hello/g' sed: Missing newline at end of file standard input. "xxxxxx"hello"yyyyyy"hello"aaaaaa"hello"cccccc"hello"bbbbbb"hello"eeeeee"hello"oooooo"hello"zzzzzz"hellohello # command -v sed /usr/bin/sed 

看起来sed是责备,而不是tr …。 使用XPG4 sed似乎解决了这个问题。 至于为什么,grrrrmmm …。

编辑:实际上,当我添加一个换行到tr命令的输出,它可以同时使用两个sed版本,所以我想/ usr / bin / sed确实需要一个换行符,而/ usr / xpg4 / bin / sed是一个在这个问题上更宽容一点。