[sclug] Bash boohoo

Jonathan H N Chin jc254 at newton.cam.ac.uk
Sat Oct 25 09:05:36 UTC 2003


pieter claassen <pieter at openauth.co.uk> wrote:
> RESULT=`brctl show` # returns three lines of info on bridge info
> echo $RESULT #prints all three lines on one line
> 
> Why does the last line not honour the "\n" (0x0a)?
> 
> But more important, how do I fix this? I have explored the more esoteric
> solutions via awk etc. but I am sure that there must be a simple reason
> and solution to this problem.

A Bourne-style shell will convert runs of whitespace into a single
space. Quote if you don't want that to happen:

    echo "$RESULT"

Contrast:

    echo  hello  world   this    is      a       test
    echo "hello  world   this    is      a       test"


-jonathan

-- 
Jonathan H N Chin, 1 dan | deputy computer | Newton Institute, Cambridge, UK
<jc254 at newton.cam.ac.uk> | systems mangler | tel/fax: +44 1223 335986/330508

                "respondeo etsi mutabor" --Rosenstock-Huessy



More information about the Sclug mailing list