Re: Reading Variables
From: Robbie Clark (rclark_at_getnetworked.com)
Date: 05/05/03
- Next message: Chris F.A. Johnson: "Re: Reading Variables"
- Previous message: joe_at_invalid.address: "Re: Reading Variables"
- In reply to: joe_at_invalid.address: "Re: Reading Variables"
- Next in thread: Chris F.A. Johnson: "Re: Reading Variables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 5 May 2003 10:48:43 -0500
I guess I'm lost. I've never used read to pull from a data file. (only to
get keyboard input).
I tried
read var1 var2 < data.file
and got the data fields from the first record fine.
How do I go to the next record to get r2d1 and r2d2 into var1 and var2?
Thanks,
<joe@invalid.address> wrote in message
news:m3llxlo2ut.fsf@invalid.address...
> "Robbie Clark" <rclark@getnetworked.com> writes:
>
> > Another newbie question. . . .
> > Is it possible to read variables from a data file into a shell script?
> > (linux bash)
> > I'd like to loop through a data file structured as such . .
> > r1d1 r1d2
> > r2d1 r2d2
> > r3d1 r3d2
>
> > I'd like to pull in r1d1 and r1d2 into separate variables, then loop
> > again to pull r2d1 and r2d2 (no punn intended) into the same
> > variables, and so on until the end of the data file.
>
> Use read, it does field splitting for you.
>
> Joe
- Next message: Chris F.A. Johnson: "Re: Reading Variables"
- Previous message: joe_at_invalid.address: "Re: Reading Variables"
- In reply to: joe_at_invalid.address: "Re: Reading Variables"
- Next in thread: Chris F.A. Johnson: "Re: Reading Variables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|