Skip to content
Advertisement

Linux awk command with pipe

Can anyone tell me what the below linux command does:

tail -5 test.log | grep 'Start Calculate' | awk '{print $1}'

I know tail -5 test.log | grep 'Start Calculate' looks for the 5 last lines containing ‘Start Calculate’ in test.log. But then I don’t get what awk does?

Advertisement

Answer

tail -5 test.log take the 5 last lines of the test.log file

then

grep 'Start Calculate' filter to keep only the lines containing ‘Start Calculate’

then

awk '{print $1}' take the first column of each line (using space as the separator between columns)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement