On Thu, Mar 30, 2006 at 07:39:34PM -0500, T wrote: > On Wed, 29 Mar 2006 20:18:07 -0600, Sumo Wrestler (or just ate too much) > wrote: > > >> the command printf seems to be ignoring the ending '\n' that passes to > >> it: > >> > >> [...] > > > > It's an interaction between the echo command and the shell that's causing > > the trailing \n to be removed. Printf is working just fine: $ printf > > "hello\n" | od -t x1 - > > 0000000 68 65 6c 6c 6f 0a > > 0000006 > > This is the correct output. But what happens when you use echo: $ echo > > -n `printf "hello\n\n\n\n\n"` | od -t x1 - 0000000 68 65 6c 6c 6f > > 0000005 > > oh, thanks for the input. It really made me thinking, and I found that it > is not echo's fault, because the previous \n was printed ok. here is more > test: > > $ echo -n "`printf "hello\n\n"`" | od -t x1 - > 0000000 68 65 6c 6c 6f > 0000005 > > but: > > $ echo -n "`printf "hello\n\n "`" | od -t x1 - > 0000000 68 65 6c 6c 6f 0a 0a 20 > 0000010 > > So is it bash that is eating the trailing \n's?
Perhaps I'm missing something... but you're still using echo. According to echo(1): -n do not output the trailing newline In the first example you indeed have trailing newlines, while in the second there's a trailing space and so no trailing newline. This looks consistent to me. -- Ken Irving, [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]