[mdlug] Scripting - Newlines getting clobbered?

Robert Meier eaglecoach at wwnet.com
Thu Dec 27 00:21:20 EST 2007


Greg,

>>> Any ideas how to keep the newline inside of variables?
>> Sure, just use quotes, like this:
>>
>> VAR="`cat data`"
>> echo "$VAR"
> Marvelous!  Worked like a charm.

Consider habitually quoting any shell substitution you read non-numerically.
Once the habit is ingrained, the unnecessary quotes are painless,
and the absence of pesky shell errors due to mishandling whitespace
(e.g. spaces in filenames),
is well worth the time or so in a hundred that you overquote.

Hopefully helpful,
-- 
Robert Meier

  "I usually take a two hour nap from one to four."
     -- Yogi Berra



More information about the mdlug mailing list