[NCLUG] bash question

Michael Milligan milli at acmeps.com
Wed May 2 02:29:35 MDT 2007

Sean Reifschneider wrote:
> On Fri, Apr 27, 2007 at 07:00:07PM -0600, Warren Turkal wrote:
>> Is is the outer echo, or is it bash getting rid of it? Is it proper
>> behavior?
> "-n" removes the trailing newline, which is obviously what is happening
> when you play with it a bit:
>    guin:~$ echo "$(echo -ne "\n")" | od -c 
>    0000000  \n
>    0000001
>    guin:~$ echo -n "$(echo -ne "\n")" | od -c
>    0000000
>    guin:~$ 

Wow, I would not have expected either of these to work because the
double-quotes on the inner echo are not escaped...  clearly, I have been
underestimating the power of ( ) .

> This may well be a bug in echo, because the documentation says that it just
> doesn't add a trailing newline, but clearly what is happening is that the
> trailing newline is being stripped, whether echo added it or not.

Sure looks that way to me as well.  Of course, source code doesn't lie.
 Documentation often does.


Michael Milligan                                   -> milli at acmeps.com

More information about the NCLUG mailing list