% ping -c 3 stackexchange.com | rev >/tmp/rping

saves the result of pinging and reversing. I would like to do this while at the same time printing the unreversed output of ping to the terminal. I would like to do this in real time, not all at once after ping is finished. Is that possible?


Using tee:

ping -c 3 stackexchange.com | tee /dev/tty | rev >/tmp/rping
  • thanks! somehow i had convinced myself that this would be delayed. – Toothrot Dec 13 '19 at 18:56

Let tee duplicate the output from ping to rev using a process substitution (assuming you are using a shell that supports these) and to the terminal:

$ ping -c 3 stackexchange.com | tee >(rev >/tmp/rping)
ping: Warning: stackexchange.com has multiple addresses; using
PING stackexchange.com ( 56 data bytes
64 bytes from icmp_seq=0 ttl=52 time=18.887 ms
64 bytes from icmp_seq=1 ttl=52 time=18.514 ms
64 bytes from icmp_seq=2 ttl=52 time=18.508 ms

--- stackexchange.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 18.508/18.636/18.887/0.177 ms

There will be no delays in the output of the above text from ping.

$ cat /tmp/rping
setyb atad 65 :) moc.egnahcxekcats GNIP
sm 788.81=emit 25=ltt 0=qes_pmci : morf setyb 46
sm 415.81=emit 25=ltt 1=qes_pmci : morf setyb 46
sm 805.81=emit 25=ltt 2=qes_pmci : morf setyb 46

--- scitsitats gnip moc.egnahcxekcats ---
ssol tekcap %0.0 ,deviecer stekcap 3 ,dettimsnart stekcap 3
sm 771.0/788.81/636.81/805.81 = ved-dts/xam/gva/nim pirt-dnuor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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