Unix commands - tail

/ #Bash


In this short post, I'll explain how and what you can do with the unix command "tail"

The "tail" command is a function I use multiple times during a day. You use this command to get contents from a file. I often use it to get the last 10 entries in a log file.

To get the 10 last lines, you do this:

tail error.log

If you want to get the last 50 lines, you can add a parameter like this:

tail -n 50 error.log

But an equal important usage of "tail" is that you can "follow" the end of the file. Let say that you want to check the outputs of a log file when you open a website.

tail -f error.log

To achieve this, you add the "-f" parameter. Doing this, all the contents that comes into the file will be outputted to the screen until you stop the process.


Comments

No comments yet...

Add comment

Newsletter

Subscribe to my weekly newsletter. One time per week I will send you a short summary of the tutorials I have posted in the past week.