Do someone know how to run a command for every line emitted in a unix pipe? I tried the oneliner in the linked story using Mac OS X’s `say`, but it doesn’t work with pipes.
cat input |while read a; do do_something_with $a; done
The best ping story I've ever heard
21–30 of 49 posts
Re: The best ping story I've ever heard
#22Do someone know how to run a command for every line emitted in a unix pipe? I tried the oneliner in the linked story using Mac OS X’s `say`, but it doesn’t work with pipes.
xargs -n1 (-n is so it executes the command for each input) You'll also need sed -l to limit buffering. ping | sed -l 's/.*/ping/' | xargs -n1 say
Re: The best ping story I've ever heard
#23This is a good one too, although not strictly ping related. http://www.ibiblio.org/harris/500milemail.html
Re: The best ping story I've ever heard
#24Do someone know how to run a command for every line emitted in a unix pipe? I tried the oneliner in the linked story using Mac OS X’s `say`, but it doesn’t work with pipes.
Re: The best ping story I've ever heard
#25This is a good one too, although not strictly ping related. http://www.ibiblio.org/harris/500milemail.html
There's also this legendary Amazon review, which is strictly ping-related: http://www.amazon.com/review/R2VDKZ4X1F992Q
Spectacular.
Re: The best ping story I've ever heard
#26We once had an Ericsson MSC that only replied to _uneven_ ICMP packets due to some bug. Made it look like there was 50% packet loss on an otherwise perfectly good Cat 5 cable... (edit: ICMP instead of IP)
Re: The best ping story I've ever heard
#27http://bash.org/?5273 Surely most people reading this will know the quote linked without having to even click it.
Re: The best ping story I've ever heard
#28http://bash.org/?5273 Surely most people reading this will know the quote linked without having to even click it.
Re: The best ping story I've ever heard
#29Re: The best ping story I've ever heard
#30Earlier quoted context omitted.
You might want to use "--unbuffered" flag in sed execution.
that option appears to be gnu-specific. -l should make it line-buffered
The only options in POSIX sed are -e, -f and -n (and -e is usually cargo-culted by people who want -E. -E being a BSD extension enabling extended regular expressions — -r in GNU sed)