grep in real time
By combining tail and grep you can achieve something pretty cool. First let’s write this simple bash script:
Save it as flowgrep, make it executable:
The syntax is very easy, just ./flowgrep <log_file> <pattern>. Let’s monitor a growing log file for numbers:
This will output lines containing at least one 1-digit number and the number(s) will be in red. To terminate the script simply press Ctrl + C
123 is a good number
July 4th is a few days away.
I feel it’s 82 degrees right now.
Note: if pattern contains space(s), use double quotations (“) to enclose it. for example: