0

I am using ssh to login to a remote server (Ubuntu), and then issue a command which outputs text/value each sec (live script).

In the live output, I want to filter out the lines containing 'dlsch_rounds'. To do so I am using command | grep 'dlsch_rounds' which gives the correct output.

UE 4aae: dlsch_rounds 22/0/0/0, dlsch_errors 0, pucch0_DTX 0, BLER 0.03874 MCS 9

Now, I want to filter this further such that it will show only BLER 0.03874.

If I use command | grep 'dlsch_rounds' | awk '{print $8}' it gives no output at all. On the other hand if I save the output in a file and the use grep and awk together, it just works fine. what am I doing wrong ?

6
  • 3
    It's possibly a matter of buffering - see similar piped command after grep not working for example Commented Apr 12 at 20:50
  • Yes, grep --line-buffered 'dlsch_rounds' solved the issue. Thank you.
    – SAM
    Commented Apr 12 at 21:47
  • 2
    ... great - however as noted in this comment you don't really need grep here at all since awk can do the record matching too Commented Apr 12 at 21:50
  • 8 is wrong by the way, assuming the default separator you want field #9 + #10. Remember that awk starts counting filed from 1, unlike other scripting / programming languages.
    – kos
    Commented Apr 13 at 2:27
  • 1
    You should be doing command | awk '/dlsch_rounds/{print $9, $10}' or similar instead of piping grep to awk.
    – Ed Morton
    Commented Apr 13 at 10:14

0

You must log in to answer this question.

Browse other questions tagged .