Text Processing – Print Only the Last Three Columns from a File

awkperltext processing

I have this file on Linux:

 14:00:01.071 5255  604177
4 14:00:01.074 4608  1415742
 14:00:01.074 18398  1122001
2 14:00:01.074 11723  155575
5 14:00:01.075 4695  885808

Desired Output:

 14:00:01.071 5255  604177
 14:00:01.074 4608  1415742
 14:00:01.074 18398 1122001
 14:00:01.074 11723 155575
 14:00:01.075 4695  885808

Command Used:

gawk '{ print $NF-1, $NF}' filename

But it prints only the last two columns.

Best Answer

$ awk '{ print $(NF-2), $(NF-1), $NF}' file1
14:00:01.071 5255 604177
14:00:01.074 4608 1415742
14:00:01.074 18398 1122001
14:00:01.074 11723 155575
14:00:01.075 4695 885808
Related Question