Follow file changes with colors

A simple command to follow-tail a file’s changes with ansi color styling.

I wanted to do something with the cool regular expression support in Bash. Of course the code could be shorter by putting the filename in $1 and the optional number of lines in $2, but where is the fun in that.

  1. Dependencies
  2. The script
  3. Usage
  4. Related stuff


Make sure you have colorizer grc installed:

sudo apt install grc

And add ~/bin to your PATH, if it isn’t already:

mkdir -p ~/bin
echo 'PATH=$HOME/bin:$PATH' >> ~/.bashrc

The script

nano ~/bin/follow


if [[ $1 =~ ^[0-9]+$ ]]; then

sudo grc tail -Fn $lines $file
chmod 0750 ~/bin/follow


$ follow [lines] file

Just track the system messages

follow /var/log/syslog

First print the last 50 lines and then follow

follow 50 /var/log/syslog

Follow a whole directory (w/o recursion)

follow /var/log/nginx/*

Leave a Reply

Your email address will not be published. Required fields are marked *