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.
Make sure you have colorizer grc installed:
sudo apt install grc
~/bin to your PATH, if it isn’t already:
mkdir -p ~/bin echo 'PATH=$HOME/bin:$PATH' >> ~/.bashrc
#!/bin/bash lines=0 file=$1 if [[ $1 =~ ^[0-9]+$ ]]; then lines=$1 file=$2 fi sudo grc tail -Fn $lines $file
chmod 0750 ~/bin/follow
$ follow [lines] file
Just track the system messages
First print the last 50 lines and then follow
follow 50 /var/log/syslog
Follow a whole directory (w/o recursion)