Re: Bash bug?
- From: Ken Irving <fnkci@xxxxxxx>
- Date: Thu, 30 Mar 2006 18:07:25 -0900
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, fnkci@xxxxxxx
--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
- References:
- Printf bug?
- From: T
- Re: Printf bug?
- From: Sumo Wrestler (or just ate too much)
- Re: Bash bug?
- From: T
- Printf bug?
- Prev by Date: Re: Unable to browse smb filesystem from nautilus in Gnome 2.12
- Next by Date: Re: email servers
- Previous by thread: Re: Bash bug?
- Next by thread: Re: Bash bug?
- Index(es):
Relevant Pages
|
|