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

  • 1
    It seems fine. What exactly do you mean by "not working"? Aug 21, 2021 at 18:12

1 Answer 1


You can do it with awk alone:

tail -f somefile.log | awk '/keyword/ {print $4}'
  • Thanks for the answer, I am trying to figure out multiple |. eg I want to run a command after print tail -f somefile.log | awk '/keyword/ {print $4}' | echo "received" >> file looks the extra | is not something to be used?
    – olo
    Aug 21, 2021 at 9:36
  • 1
    You can combine as many pipes as you want/need in one line. What exactly is not working for you?
    – digijay
    Aug 21, 2021 at 10:00
  • Thanks! I wanted to do something like tail -f somefile.log | awk '/keyword/ {print $4}' | echo {print $4}(get the result) >> filename (to another file)
    – olo
    Aug 21, 2021 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .