How to do it...

Open a terminal and run the following commands:

$ cat loremipsum.txt$ head loremipsum.txt$ head -n 1 loremipsum.txt$ tail loremipsum.txt$ tail -n 1 loremipsum.txt

Interestingly enough, the tail command has a feature that is different than the head command: it can monitor the tail end of a file forever until the command is exited or killed when using the -f or -F flags. Run the following command:

$ tail -F /var/log/kern.log

Keeping the tail command running, try disconnecting your wireless or Ethernet port. What do you see?

Press Ctrl + C to quit tail and run the following command:

$ more loremipsum.txt

Pressing the spacebar or Enter on your keyboard will progress through the file until the end. Pressing q will immediately exit ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.