I am trying to get ping to continuously write some times to a file. When I run $ ping 10 10.1.10.28 | perl -ne '/time=(\d+\.\d+)/ && print $1\n'It returns one number every several milliseconds:$ ping 10 10.1.10.28  | perl -ne '/time=(\d+\.\d+)/ && print $1\n'191.523312.225127.506However, when I redirect that to a file, and tail -f that file elsewhere, nothing happens. When I hit Ctrl-C, nothing is written to the file.How can I force ping to write to STDOUT as new data comes in?
Force ping to write before interrupt
pipe;stdout;ping;interrupt
You suffer from pipe buffering. Usually output to non interactive terminal is buffered to 4Kb blocks until delivered via pipe, so you have to disable it. You could alter your command line like this:$ stdbuf -oL ping 10.1.10.28  | perl -ne '$|=1; /time=(\d+\.\d+)/ && print $1\n' > filestdbuf is part of coreutils.$|=1; is the way to disable output buffering in perl.P.D. I have removed the extra 10 in the ping command.