Here is the video version, if you prefer it:
The head
command is used to display the first 10 lines of a file. The tail
command is used to display the last 10 lines of the file. (Barrett, 2016)
Both of the commands have an option -n
which control how many lines you want to output. By default it is 10, but you could write
head -n 12
and head
would output 12 lines at the beginning of the file.
A really cool thing about tail
is that it has the -f
option, which enables you to watch a file actively; you get new lines which are written to a file displayed. Why is this useful? Well, if you are watching some system file (a file which contains information about devices connected to your computer, for example), you could find out some information about the newly connected device.
Hope you learned something new!
References
Barrett, D. J. (2016). Linux pocket guide (3rd ed.). O’Reilly Media. Pages 60-61