Skip to main content

tail

Tail helps you keep track of the end of files and stuff!

Do a "live" tail of a file

tail -f file.txt

Tail a "live" file and send an alert when certain words are written to the file

Check out our sweet script for this!

Tail a file while grepping for a specific word at the same time

tail -f somelog.log | grep -w "hello"

Tail a Caddy log file while grepping for just the source IP, timestamp, and requested URL

sudo tail -f /var/log/caddy/somelog.log | grep --line-buffered -oP '^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}|(?<="remote_ip": ")[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|(?<="uri": ")[^"]+' | awk 'NR%3==1{timestamp=$0; next} NR%3==2{ip=$0; next} $0!="/"{print "Timestamp: " timestamp ", Source IP: " ip ", Requested URI: " $0}'