Re: Reading Variables
From: Robbie Clark (rclark_at_getnetworked.com)
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).
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?
<firstname.lastname@example.org> wrote in message
> "Robbie Clark" <email@example.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.