can any1 please tell me what is problem with following code:
i=1;
cat test| while read CMD;
do
Var$i=$CMD; or Var$i=$(echo $CMD) ;
let i++
done
I keep getting error :
line 4: Var1=sometext: command not found
can any1 please tell me what is problem with following code:
i=1;
cat test| while read CMD;
do
Var$i=$CMD; or Var$i=$(echo $CMD) ;
let i++
done
I keep getting error :
line 4: Var1=sometext: command not found
that's a useless use of cat. and for your problem use following
i=1;
while read CMD
do
eval Var$i=$CMD
let i++
done < test
That's a useless use of eval, and eval is dangerous -- someone could feed text like `rm -Rf ~/`
into the program, and it would do it.
Just do this instead:
i=1
while read var$i
do
let i++
done <inputfile