views:

20

answers:

1

Hi all,

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

+2  A: 

Maybe it is because you replaced the last newline with a comma. So non GNU sed and awk just stop on end of file and do not parse the line because it is not terminated by \n.

Peter van der Heijden
Yes, you're probably correct I just used `awk` to remove the newlines and the result is the same. Just going verify the result via avoid removing the last `\n`
Anders
Indeed this was the correct answer.
Anders