Hi,
there is a file which contains some values in column format. I want to store those values in a variable.but when i am using awk it is storing all the values at a time.
x=`awk '{print $1}' test2.txt`
echo $x
ab cd mn jk yt
but i want the values to be stored one by one in that variable.
like
x=`awk '{print $1}' test2.txt`
echo $x
ab
echo $x
cd
suggestions please.
Try:
while read x rest; do
echo "$x"
done < test2.txt
actually my input file is in this format
timestamp errormessage errorcode description
from this file i want to pickup the errorcode column and store it in some variable. but when i using awk it is storing all the values inside that column in that variable.i want one value at a time in that variable.
I am using awk as i want to pick a column from a file.
while read timestamp errormessage errorcode description
do
echo "Error code: $errorcode"
done < test2.txt
Is error message one word? Otherwise please post a sample of your input file.