Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Reading line by line
- X-seq: zsh-users 11378
- From: Micah Cowan <micah@xxxxxxxxxx>
- To: meino.cramer@xxxxxx
- Subject: Re: Reading line by line
- Date: Tue, 10 Apr 2007 20:56:49 -0700
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20070411033311.GA6837@solfire>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070411033311.GA6837@solfire>
meino.cramer@xxxxxx wrote:
> Hi,
>
> how can I read line by line from a file of text?
>
> I tried
>
> while theline in `cat results.txt`
> do
> echo ${theline}
> echo "----------------"
> done
>
> and got a new echo on every _blank_ seperated word and
> not a every new line seperated by a newline.
>
> Thank you very much for any help in advance!
> Keep zshing!
I'm assuming you meant "for" not "while"?
The `cat results.txt` will expand into the contents of results.txt,
which will then typically be split apart on wordspace, just as tokens
are normally split in a shell.
You probably want something more like:
while read theline
do
echo ${theline}
echo "---------------"
done < results.txt
HTH,
--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author