Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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.
如果修改您的命令以确保ping正确完成,而不是<ctrl-c>例如。
ping
<ctrl-c>
ping -c 5 -i 10 host | perl -nle 'print scalar(localtime), " ", $_' > output.txt
那么这听起来真的像是一个缓冲问题。您可以perl使用$| = 1.
perl
$| = 1
ping -i 10 host | perl -nle '$|++; print scalar(localtime), " ", $_' > output.txt