You do not see anything due to buffering. The output is displayed when there are enough lines or the end of the file is reached. tail -f means waiting for more input, but there are no more lines in file , and therefore the channel to grep never closes.
If you omit -f from tail output will be shown immediately:
tail file | grep A1 | awk '{print $NF}'
@Edmorton is, of course, right. Awk can also search for A1 , which shortens the command line to
tail file | awk '/A1/ {print $NF}'
or without tail, showing the last column of all rows containing A1
awk '/A1/ {print $NF}' file
Thanks to the comment, @MitchellTracy tail can skip a record containing A1 and thus, you wonβt get anything at all. This problem can be solved by switching tail and awk , awk search first in the file, and then showing the last line:
awk '/A1/ {print $NF}' file | tail -n1
Olaf Dietsche Oct 24 '12 at 9:17 2012-10-24 09:17
source share