On Wednesday 13 December 2006 21:22, Pascal Nunes wrote:
> hi,
>
> I am writing a shell script where I retrive values from a text file using
> cut. I want to save these into variables.
>
> The script is something like this...
>
> grep searchtext file | cut -f 1,3,7,8
>
> I want to save the values returned by cut into 4 different variables.
>
> Can anyone suggest a method to save these values into multiple variables?
>
> Is there any better method to do this?

Now that I'm back home, here's a good method, without using multiple for 
loops:

#!/bin/bash
num=1
for i in $(grep Hubert list | cut -f 1,3,7,8); do
        eval var$((num++))=$i
done

The values will be stored in variables $var1 $var2 $var3 and $var4.

-- 
----------------------------------------
Mrugesh Karnik
GPG Key 0xBA6F1DA8
Public key on http://wwwkeys.pgp.net
----------------------------------------

Attachment: pgpRZZriPtFAr.pgp
Description: PGP signature

-- 
http://mm.glug-bom.org/mailman/listinfo/linuxers

Reply via email to