0

I need redirect the below command to a file.

ping -i 10 host | perl -nle 'print scalar(localtime), " ", $_'

I have trying with > output.txt and >> output.txt and It doesn't working.

Tks.

4

1 回答 1

2

如果修改您的命令以确保ping正确完成,而不是<ctrl-c>例如。

ping -c 5 -i 10 host | perl -nle 'print scalar(localtime), " ", $_' > output.txt

那么这听起来真的像是一个缓冲问题。您可以perl使用$| = 1.

ping -i 10 host | perl -nle '$|++; print scalar(localtime), " ", $_' > output.txt
于 2013-07-08T16:12:53.437 回答