Strangeness using /usr/xpg4/bin/tr and /usr/bin/tr on Solaris 9
I have a file looking like this,
"xxxxxx"
"yyyyyy"
"aaaaaa"
"cccccc"
"bbbbbb"
"eeeeee"
"oooooo"
"zzzzzz"
Wanting to replace each n in this file I use:
tr 'n' ',' < INPUT > OUTPUT
Which works fine. The output is to be expected:
"xxxxxx","yyyyyy","aaaaaa","cccccc"....
However
I can’t do any manipulation using sed or awk on this file, none what so ever (the result is always blank, like: sed 's/,/hello/g' displays nothing), in Linux using the GNU package this works fine, but with non GNU not. Can anyone tell me why this is?
Thanks in advance,
Anders
# 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
It seems sed is to blame, not tr … . Using XPG4 sed does seem to fix the problem. As to why exactly, grrrrmmm… .
Edit: actually, when I add a newline to the output of the tr command, it does work with both sed editions, so I suppose /usr/bin/sed really needs a newline, and /usr/xpg4/bin/sed is a little more forgiving on the matter… .
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
- Windows File Permissions and Attributes
- What is the easiest way to upgrade my existing Perl 5.14 to Perl 5.16 on FreeBSD 9 using the ports system?
- Know if mysql has done its job
- Redirect https .com to https .co.uk without a valid SSL cert on .com without DNS change
- Why is it a bad idea to use customer email as from address





