DEV Community 👩‍đŸ’ģ👨‍đŸ’ģ

Cover image for Living in the Shell #20; tail (Display/Follow File Content)
Babak K. Shandiz
Babak K. Shandiz

Posted on • Originally published at babakks.github.io on

Living in the Shell #20; tail (Display/Follow File Content)

tail â›ĩ

Display or follow file content.

ℹī¸ Here, following means streaming a file while it's being updated (appended).

ℹī¸ You can use -c in place of -n in the following examples, to switch to binary offset selection.

Print bottom N lines of a file -n

tail -n 5 ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Prints last 5 lines of ~/.bashrc

Print from N-th line afterwards -n +N

tail -n +3 ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Prints ~/.bashrc from the 3rd line until the end.

Following syslog events -f

tail -f /var/log/syslog
Enter fullscreen mode Exit fullscreen mode

Follows system logs (on Debian/Ubuntu).

Top comments (0)

Regex for lazy developers

regex for lazy devs

You know who you are. Sorry for the callout 😆