如何只保存最后一次 ping 结果(使用 linux 终端)?
How can I save just the last result of ping (using linux terminal)?
我有这个 bash 命令波纹管(我认为这是 bash)但它并没有覆盖最后的结果。我试过只有一个“>”和“>|”同样,但没有成功。
我的目标是使用 linux 终端(我使用 Ubuntu 18.04).
while true; do (ping www.whosebug.com) >> rtt_test.txt; sleep 5; done
要使 ping 退出而不必按 cntrl+c,请使用 -c <number of pings to send>
或 -w <number of seconds to run for>
。然后使用单个 >
每次都会用新结果替换输出文件。
如果您只需要发送单个 ping 的时间,可以使用 ping -c 1 www.whosebug.com | head -2 | tail -1 | cut -d "=" -f 4 > myfile
。
我有这个 bash 命令波纹管(我认为这是 bash)但它并没有覆盖最后的结果。我试过只有一个“>”和“>|”同样,但没有成功。
我的目标是使用 linux 终端(我使用 Ubuntu 18.04).
while true; do (ping www.whosebug.com) >> rtt_test.txt; sleep 5; done
要使 ping 退出而不必按 cntrl+c,请使用 -c <number of pings to send>
或 -w <number of seconds to run for>
。然后使用单个 >
每次都会用新结果替换输出文件。
如果您只需要发送单个 ping 的时间,可以使用 ping -c 1 www.whosebug.com | head -2 | tail -1 | cut -d "=" -f 4 > myfile
。