Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: lines as array elements
- X-seq: zsh-users 922
- From: stephen.talley@xxxxxxxxxxxxxxx (Steve Talley)
- To: unpingco@xxxxxxxxxxxx
- Subject: Re: lines as array elements
- Date: Fri, 27 Jun 1997 17:00:49 -0600
- Cc: zsh-users@xxxxxxxxxxxxxxx
Try:
#!/bin/zsh
IFS="
"
i=1;
for line in `cat file`
do
x[$i]=$line
i=`expr $i + 1`
done
Steve
> From zsh-users-request@xxxxxxxxxxxxxxxxxxxxxxxx Fri Jun 27 16:53 MDT 1997
> From: unpingco@xxxxxxxxxxxx (Jose Unpingco)
> Subject: lines as array elements
> To: zsh-users@xxxxxxxxxxxxxxx (zsh)
> Date: Fri, 27 Jun 1997 15:38:18 -0700 (PDT)
>
> hi,
>
> I have a file that looks like this:
>
> -503 306 -498 428
> -500 435 -501 588
> -497 440 -501 593
> -505 451 -502 601
> -510 324 -511 454
> -505 328 -511 459
> -506 333 -509 464
> -520 342 -492 463
>
> what I'd like to do is get each line into an array element like
>
> x[1]="-503 306 -498 428"
>
> up to
>
> x[8]="-520 342 -492 463"
>
> I've tried x=(`cat file`) but that splits on the spaces between the
> numbers. I've looked at the IFS variable and tried to change it to
> newline but that doesn't work as expected.
>
> Thanks.
>
> --
> Thank you for your time and consideration.
>
> _ - - - _
> /)- - _ _
> / |_o_/ - _
> \__ - _
> \ \_ - _ _ _ _ _ _ _ _ _
> _
> __ __ _ _ -
> Jose Unpingco Mail Code ECE 0407
> WK# (619) 534-5904
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author