I am trying to parse a file just like:
for NAME in `cat file.txt | grep name | awk '{print $2}'`
do
echo " $NAME "
......
done
file.txt content:
name John box 2
name Joe box 3
name May box 4
Then it will print:
John
Joe
May
But now I want to get box number in the meantime, I need to store name and box in two variables, how to do this?
Expected result:
echo "$NAME $BOX"
John 2
Joe 3
May 4