[Eug-lug] Reading data to multiple variables
Allen Brown
allen_brown at agilent.com
Wed Jul 28 11:41:47 PDT 2004
If you don't mind using the command line array, you can
use set to do this.
$ set - $(echo 05e307020000000000000000 Yes)
$ echo $1
05e307020000000000000000
$ echo $2
Yes
Is this what you had in mind?
--
Allen Brown
work: Agilent Technologies non-work: http://www.peak.org/~abrown/
allen_brown at agilent.com abrown at peak.org
Socialism is like a dream. Sooner or later you wake up to reality.
--- Sir Winston Churchill
Garl Grigsby wrote:
>
> I need a bit of bash help. I have a situation where I need to read
> two pieces of data from a text file and store these data into two
> variables. I know that this would be easy in perl, but I have to do this
> as a shell script. The data will be a number and a word, like this:
> "05e307020000000000000000 Yes".
> I know that I could simple get the data in two separate operations,
> but the problem is that there could be either 1, 2, 3, or 4 pairs of
> data, and while I could still do this will multiple steps, I would
> prefer to find a more elegant way. What I would really like to do would
> be to store this data in an array. The problem is that I cannot figure
> out how to store the data in the array. I've tried something like this:
>
> myarray[*] = awk `my awk foo`
>
> or this
>
> myarray[*] = awk `my awk foo`
>
> but bash complains about a bad array subscript. So does anybody feel
> like learning me some bash?
>
> Thanks,
> Garl
> _______________________________________________
> EUGLUG mailing list
> euglug at euglug.org
> http://www.euglug.org/mailman/listinfo/euglug
More information about the EUGLUG
mailing list