0

I am using command like timeout 10 ping 8.8.8.8 | tail -2.

Here I am getting output as Terminated. But I need the last two lines of ping.

Can any one please tell what to do

0

I have to use &> operator.

timeout 10 ping 8.8.8.8 &>out.txt and cat out.txt | tail -2 would give the last two lines of ping

0

You have found an answer, but you could also try

ping -w10 8.8.8.8

This tells ping to keep pinging for 10 seconds, then to stop.

  • ping is just an example. I want that functionality – karra Nov 1 '18 at 13:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.