On Aug 2, 2007, at 6:06 PM, David Livesay wrote:
> BTW, can anyone recommend a good book on shell scripting for
> someone who doesn't intend to make a career of it--just get a few
> things done? I've done about all I can with man pages.
I use "Learning the bash Shell", Cameron Newham and Bill Rosenblatt,
O'Reilly. Third Edition, 2005. (I need to replace my Second
Edition, which was 1998). ISBN 0-596-00965-8.
And I just got the brand new (in mid-July, although the claimed first
printing is May 2007), "Bash Cookbook", Carl Albing, JB Vossen and
Cameron Newham. O'Reilly, ISBN 0-596-52678-4
Get "Learning" first. If you want to move on from there, then add
Cookbook.
As to your missing whitespace, you could try replacing the
echo $i
with
echo "$i"
That has to be double-quotes--single quotes would cause your output
to be a series of lines containing the literal $i
That should present the whole line to echo as a single argument, and
in that case echo won't mess with whitespace inside the argument.
With just $i, the $i is indeed the whole line, but echo sees it as a
series of arguments (word-like things), and emits them with a space
separating them.
An alternative would be to replace the echo with col, but I think
that would have trouble with any line starting with a hyphen.
And another alternative would be to mess with the environment
variable IFS (Internal Field Separator), but I'd suggest not going
there unless you simply want to play (and waste an afternoon).
--John
|