Print the last line of a file, from the CLI

$ cat file | awk 'END{print}'

Originally answered by Ventero


Use the right tool for the job. Since you want to get the last line of a file, tail is the appropriate tool for the job, especially if you have a large file. Tail's file processing algorithm is more efficient in this case.

tail -n 1 file

If you really want to use awk,

awk 'END{print}' file

EDIT : tail -1 file deprecated


Is it a must to use awk for this? Why not just use tail -n 1 myFile ?