Reply
Thread Tools
Posts: 2,076 | Thanked: 3,268 times | Joined on Feb 2011
#1
Not sure if this is possible with sed, but after a bit of googling I believe this is the right tool. I am trying to replace MAC addresses of my devices with human-friendly names. I created a file with 's/MAC/Laptop/g' lines and for cat it works:

cat file.csv | sed -f list (this replaces mac addresses as expected)

but real-time output doesn't:

airodump-ng wlan0 | sed -f list (no substitution takes place)

Can this be achieved with sed?

Last edited by szopin; 2011-11-24 at 20:11.
 
Posts: 99 | Thanked: 65 times | Joined on Jan 2008 @ Finland
#2
Originally Posted by szopin View Post
but real-time output doesn't:

airodump-ng wlan0 | sed -f list (no substitution takes place)

Can this be achieved with sed?
This doesn't have anything to do with sed. sed cannot edit your data if it doesn't get it. Instead, this has everything to do with output buffering. Try the following to commands (also without pipe to sed) and you'll iunderstand what I mean.

Code:
perl -e '$| = 0; foreach (1..5) { print "$_\n"; sleep(1); }' | sed 's/2/XYZZY/; s/4/foobar/'
perl -e '$| = 1; foreach (1..5) { print "$_\n"; sleep(1); }' | sed 's/2/XYZZY/; s/4/foobar/'
In other words, you'll have do disable output buffering from airodump-ng or whatever application you use to generate the data.

Last edited by wnd; 2011-11-23 at 20:11. Reason: lets only run for five seconds
 

The Following 3 Users Say Thank You to wnd For This Useful Post:
Posts: 2,076 | Thanked: 3,268 times | Joined on Feb 2011
#3
Courtesy of Reddit user xaoq:

airodump-ng wlan0 2>&1 | sed -f list.txt

explanation: airodump-ng apparently dumps data into stderr, not stdout. Hence the redirect stderr -> stdout.
 
Posts: 99 | Thanked: 65 times | Joined on Jan 2008 @ Finland
#4
Originally Posted by szopin View Post
but real-time output doesn't:

airodump-ng wlan0 | sed -f list (no substitution takes place)
I feel so dumb. I somehow read this as "substitution doesn't work in real time". My mistake.
 

The Following 2 Users Say Thank You to wnd For This Useful Post:
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#5
@wnd,

Still. Your reply was spot on, at least in the general case.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 09:05.