From: stephen.talley@Central.Sun.COM (Steve Talley)
To: unpingco@mpl.ucsd.edu
Cc: zsh-users@math.gatech.edu
Subject: Re: lines as array elements
Date: Fri, 27 Jun 1997 17:00:49 -0600 [thread overview]
Message-ID: <199706272300.RAA00662@ipecac.Central.Sun.COM> (raw)
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@euclid.skiles.gatech.edu Fri Jun 27 16:53 MDT 1997
> From: unpingco@mpl.ucsd.edu (Jose Unpingco)
> Subject: lines as array elements
> To: zsh-users@math.gatech.edu (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
>
>
next reply other threads:[~1997-06-27 23:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-27 23:00 Steve Talley [this message]
1997-06-28 5:15 ` Geoff Wing
-- strict thread matches above, loose matches on Subject: below --
1997-06-27 22:38 Jose Unpingco
1997-06-28 6:03 ` Zoltan Hidvegi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199706272300.RAA00662@ipecac.Central.Sun.COM \
--to=stephen.talley@central.sun.com \
--cc=unpingco@mpl.ucsd.edu \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).