Sobes.tech
Senior

What command can be used to view the last 20 lines of a text file or log?

sobes.tech AI

Answer from AI

To view the last 20 lines of a text file or log, use the tail command with the -n option:

 tail -n 20 filename.log

If you want to monitor the file for updates in real-time, you can add the -f option:

 tail -n 20 -f filename.log

This will show the last 20 lines and continue to display new lines as they are added to the file.