MACSCRPT Archives

August 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
David Livesay <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 3 Aug 2007 17:34:39 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (48 lines)
On Aug 3, 2007, at 11:37 AM, John Baxter wrote:

> Compare these two:
>
> $echo This     is      a     test.
> This is a test.
> $echo "This     is      a     test."
> This     is      a     test.
>
>
> In the first, echo gets four "words"---in the second it gets one.
>
> In the loop in your original message, echo has no idea about  
> anything named $i--it only knows what the system has given it--a  
> bunch of "words" when the quotes were absent vs a single "word"  
> with the quotes present (it doesn't see the quotes).  Thus...
>
> $i="This     is      a     test."
> $echo $i
> This is a test.
> $echo "$i"
> This     is      a     test.
>
> (In all cases there INCLUDING the assignment, the leading $ on the  
> lines that have it is the shell prompt.  So in the first one, the  
> command is
>    i = ....
> )
>
> Continuing...
> $j="'Twas brillig,               and the slithy toves"
> $echo "$i" "$j"
> This     is      a     test. 'Twas brillig,               and the  
> slithy toves
> $echo "$i$j"
> This     is      a     test.'Twas brillig,               and the  
> slithy toves
>
> and even
> $echo "$i      $j"
> This     is      a     test.      'Twas brillig,               and  
> the slithy toves
>
>    --John

I understand that, but how do you get cat to put quotes around each  
line?

ATOM RSS1 RSS2