2

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.

5
  • 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. Oct 15, 2016 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, 2016 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. Oct 15, 2016 at 10:17
  • interestingly enough it works with top.very strange!maybe the problem is with airodum-ng!
    – Kasra
    Oct 15, 2016 at 10:21
  • Are you sure the search strings are actually present? Pipe the stream into less +F to check this point. You can even search for your terms in less command. Dec 5, 2023 at 16:30

2 Answers 2

0

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

3
  • 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. Aug 22, 2017 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, 2017 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 Aug 22, 2017 at 21:14
-1

You can use the command watch for this.

For example:

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

You must log in to answer this question.

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