by robinhouston · 13y ago · 0 comments
ping google.com | perl -ne '/time=(.*)/ && system("say", $1)'
Of course it’s only a little more awkward in Ruby: ping google.com | ruby -ne '$_ =~ /time=(.*)/ && system("say", $1)'
(No criticism is intended of your perfectly fine code. I enjoy comparing different ways to do things like this, and perhaps others do too.) ping google.com | python -c 'import os,re,sys; [os.system("say %s" % j[0]) for j in (re.findall("time=(.*)", i) for i in sys.stdin) if j]'
I'm sure someone can come up with a shorter one-liner, but in general I think Python is simply too verbose for this kind of stuff.ping -i 5 8.8.8.8 | perl -ne '/time=(.*)/ && system("say", $1)'
ping g.cn | node -e "process.stdin.on('data',function(l){require('child_process').exec('say '+/time=([0-9]*)/g.exec(l+'')[1])}).resume()"