Zsh Mailing List Archive
Messages sorted by:
Re: Reading line by line
- X-seq: zsh-users 11381
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: djh <henman@xxxxxxxxxxxxxx>
- Subject: Re: Reading line by line
- Date: Wed, 11 Apr 2007 08:29:23 +0100
- Cc: Zsh Users List <zsh-users@xxxxxxxxxx>
- In-reply-to: <20070411155509.2180@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: djh <henman@xxxxxxxxxxxxxx>, Zsh Users List <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070411033311.GA6837@solfire> <461C5C81.20609@xxxxxxxxxx> <20070411063800.GA4996@xxxxxxxxxxxxxxx> <20070411155509.2180@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
On Wed, Apr 11, 2007 at 03:55:09PM +0900, djh wrote:
> > > meino.cramer@xxxxxx wrote:
> > > > how can I read line by line from a file of text?
> > Most Unix tools (cut, paste, sed, awk...) read files lines by
> > line, it's generally a bad idea to have the shell read the file
> > by itself.
> I shouldn't think so. Nothing wrong with reading in lines from a file.
> It should in fact be easier and more efficient than have to load in heavy tools
> like sed, if they're not needed.
You're thinking of the shell as of a programming language, not a
shell. A shell is a command line interpreter before all, if you
want to do shell processing *programmatically*, use perl or
ruby, that's what they are good at. Then, use a shell as a
shell, and zsh is the best one at it. You may use while read
loops for speeding up code when writing shell extensions (like
That's my view anyway.
> > > while read theline
> Read "Chapter 17, Shell Builtin Commands"
> read .. explains all options for the shell builtin "read"
> getln.. a related function equivalent to "read -zr"
That's to read from the editor buffer stack!
To read a line of input, well all characters til the next
newline character or the end-of-file and store it into a
IFS= read -r line
is something totally different.
Messages sorted by: