[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: weird echo behaviour...
From: |
P |
Subject: |
Re: weird echo behaviour... |
Date: |
Thu, 16 Sep 2004 16:33:16 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040124 |
Alfred M. Szmidt wrote:
Could someone explain the following behaviour for me? Because I sure
do not understand it.
Yes this is confusing but not incorrect.
address@hidden:/tmp/foo$ touch 1 2 3 4 5
address@hidden:/tmp/foo$ foo=`ls`
$foo will contain the string 1\n2\n3\n4\n5\n
address@hidden:/tmp/foo$ /bin/echo $foo
1 2 3 4 5
This will first parse the string into seperate
parameters to pass to echo which it outputs with spaces in between
address@hidden:/tmp/foo$ /bin/echo "$foo"
1
2
3
4
5
The quotes stop the parsing of the string into seperate params,
so echo will output the unparsed string containing newlines.
Pádraig.
- weird echo behaviour..., Alfred M. Szmidt, 2004/09/16
- Re: weird echo behaviour..., Bob Proulx, 2004/09/16
- Re: weird echo behaviour..., Andreas Schwab, 2004/09/16
- Re: weird echo behaviour..., Dmitry V. Levin, 2004/09/17
- Re: weird echo behaviour...,
P <=
- Re: weird echo behaviour..., Philip Rowlands, 2004/09/17