Linux cli pipeline command tail and grep
I am using tail to monitor a log file and using grep to filer the keyword.
tail -F somefile.log | grep "keyword"
is working
tail -F somefile.log | awk '{print $4}'
is working
but if to put them together is not working, like tail -F somefile.log | grep "keyword" | awk '{print $4}'
Is this the wrong way to use |
? How to make tail -F somefile.log | grep "keyword" | awk '{print $4}'
to work? Thanks
if I want to run a command after awk like tail -F somefile.log | grep "keyword" | awk '{print $4}' | ./abashfile.sh
how to achieve something like this, looks like multiple |
is not quite right for combining everything in 1 line. Thanks
Solution 1:
You can do it with awk
alone:
tail -f somefile.log | awk '/keyword/ {print $4}'