i can do
tail -f -n20 <file> to see the last 20 lines of the file, live.
If i want to grep something,
tail -f <file> | grep <pattern>, it will still be live, but will only grep through the output of tail, meaning I am not gaurunteed 20 lines of output at first. (if only 5 of 20 lines match my pattern, I only get 5 lines out of output)
If I do something like
grep <pattern> <file> | tail -n20
I am gaurunteed 20 lines of output but it isn't live, nor is
cat <file> | grep <pattern> | tail -n20
How can I see a live update of the last n lines of a file after grepping?