I have a file with many lines, like this:
one 3456 orange
two 6690 grape
three 5570 apple
four 6683 pear
five 8847 cherry
six 9035 banana
So I write a awk script to catch this output:
apple banana cherry
It looks like this:
awk '/three/ { a = $3}; /six/ { b = $3}; /five/ { c = $3} END {print a" " b" "c}' <file
But this doesn't look the best way becuase I keep using $3 - how do I catch this variable to reuse it?