As you know, there are commands such as top, watch, Airodump-ng, etc, that whenever you run, everything on the terminal change all the time. what I want to do is that run one of theses interactive command and then use pipe in order to grep something I've been looking for. Take this for instance:

   airodump-ng wlan0 | grep "QQ:AF:00:55:8C:DF"

In this example I'm looking for a MAC address, when this MAC turn up, it'll appear on screeen so that I can grep it.

the problem is that it doesn't work. I've searched a lot but I've found the answer in vain.

  • One reason you are not seeing anything might be this: waln0. Should most likely be wlan0. grep and top otherwise works fine together and produce output as expected. I have no experience of airodump-ng. – maulinglawns Oct 15 '16 at 10:03
  • I'm so sorry...I've typed wlan0 wrong...no no I'm sure. i've tried many times with different interactive command.but this method didn't work – Kasra Oct 15 '16 at 10:13
  • I still beg to differ; for example, the command top | grep X works just fine on my system (Debian 8). It produces output on X and nothing else at regular (2 seconds) intervals. – maulinglawns Oct 15 '16 at 10:17
  • interestingly enough it works with top.very strange!maybe the problem is with airodum-ng! – Kasra Oct 15 '16 at 10:21

see also the --line-buffered option of grep; it makes grep execute its test every time its stdin sees a newline

| improve this answer | |
  • 2
    No --line-buffered is for grep's output to be line-buffered like it is when it goes to a terminal device. It doesn't affect the way grep reads and processes its input. – Stéphane Chazelas Aug 22 '17 at 11:38
  • sorry, however it works, there's scenarios where long-running-process | grep foo blocks without outputting anything and long-running-process | grep --line-buffered foo outputs stuff as it is written – Plato Aug 22 '17 at 19:26
  • 1
    Yes, when grep's stdout is not a tty and when the problem is grep buffering its output. Like in tail -f file | grep . | cat – Stéphane Chazelas Aug 22 '17 at 21:14

You can use the command watch for this.

For example:

sudo watch -n 1 "airodump-ng wlan0 | grep "QQ:AF:00:55:8C:DF"
| improve this answer | |
  • I'll test now.I'll tell you the result – Kasra Oct 15 '16 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.