On 4/23/10 4:17 AM, Binarus wrote:

> The script
> 
> echo 'line1' > file
> echo 'line2' >> file
> RESULT=$(cat file)
> echo "$RESULT"
> 
> gives the following output:
> 
> line1
> line2
> 
> I don't understand why: the command substitution $(cat file) is not
> within double quotes, so word splitting should be applied to the
> result of the substitution and any embedded newlines should be
> removed. Thus, $RESULT should contain text without newlines after line
> three in the above script is executed.

The rhs of assignment statements is not subject to word splitting.
Assignment statements are treated differently than arguments to simple
commands.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/


Reply via email to