GREP and Retrieve Line by Line

Hello All,

I have a doubt in grep,

lets say using grep we have the result as four lines ....

grep -i test*

Results :

Line 1
Line 2
Line 3
Line 4

how can i reterive line 1 into a variable and line 2 into a variable etc.

Thanks

Ranjith

If your shell supports arrays, you could use those. In classic Bourne shell, this is not something which is very easy or natural to do. What's the purpose of this? Maybe you could simply use a loop, and get by with just a single variable?

grep -i test * |
while read line; do
  echo line is: "$line"
done

By the by, you should notice that "test*" is a regular expression which matches "tes", "test", "testt", "testtt", "testttt" etc.

Hey Thanks era..

Regards

Rahul