Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: kinda perl split ...
- X-seq: zsh-users 10055
- From: dom@xxxxxxxxxxxxxxxx (Dominic Mitchell)
- To: Marc Chantreux <marc.chantreux@xxxxxxxxxxxxxxxxxx>
- Subject: Re: kinda perl split ...
- Date: Tue, 21 Mar 2006 14:54:39 +0000
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <44200C25.7020103@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <442002B4.8080501@xxxxxxxxxxxxxxxxxx> <20060321135118.GA92936@xxxxxxxxxxxxxxxxxxxxxx> <44200C25.7020103@xxxxxxxxxxxxxxxxxx>
On Tue, Mar 21, 2006 at 03:22:29PM +0100, Marc Chantreux wrote:
> Dominic Mitchell wrote:
>
> > echo foo bar | while read a b junk
> > do
> > echo "a=$a b=$b"
> > done
>
> so if the separator is ':', you should redefine IFS
>
> oldIFS=$IFS
> IFS=':'
> echo foo bar | while read a b junk
> do
> echo "a=$a b=$b"
> done
> IFS=$oldIFS
> oldIFS=
>
> or with a subshell:
>
> ( IFS=':'
> echo foo bar | while read a b junk
> do
> echo "a=$a b=$b"
> done )
Or even simpler, just redefine the variable for that read command:
echo foo:bar | while IFS=: read a b junk
do
echo "a=$a b=$b"
done
-Dom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author