9

Some useful command line tools

 1 year ago
source link: https://proinsias.github.io/til/some-useful-command-line-tools
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Some useful command line tools

1 minute read

climagic posted a great example of multiple commands:

ping -c100 4.2.2.2 | sponge | pee head tail

Let’s split this command up – see this explainshell for some additional detail:

  1. ping -c100 4.2.2.2 pings the DNS server 4.2.2.2 100 times.
  2. sponge ‘soaks’ up all the data from ping.
  3. pee (tee for pipes) runs each command provided – in this case head and tail, and feeds each command a copy of the standard input. The output of all commands is sent to stdout.

Here’s an example output of the full pipeline:

PING 4.2.2.2 (4.2.2.2): 56 data bytes
64 bytes from 4.2.2.2: icmp_seq=0 ttl=56 time=40.236 ms
64 bytes from 4.2.2.2: icmp_seq=1 ttl=56 time=19.956 ms
64 bytes from 4.2.2.2: icmp_seq=2 ttl=56 time=33.536 ms
64 bytes from 4.2.2.2: icmp_seq=3 ttl=56 time=19.312 ms
64 bytes from 4.2.2.2: icmp_seq=4 ttl=56 time=21.025 ms
64 bytes from 4.2.2.2: icmp_seq=5 ttl=56 time=24.594 ms
64 bytes from 4.2.2.2: icmp_seq=6 ttl=56 time=17.206 ms
64 bytes from 4.2.2.2: icmp_seq=7 ttl=56 time=54.491 ms
64 bytes from 4.2.2.2: icmp_seq=8 ttl=56 time=16.781 ms
64 bytes from 4.2.2.2: icmp_seq=94 ttl=56 time=30.563 ms
64 bytes from 4.2.2.2: icmp_seq=95 ttl=56 time=48.805 ms
64 bytes from 4.2.2.2: icmp_seq=96 ttl=56 time=14.286 ms
64 bytes from 4.2.2.2: icmp_seq=97 ttl=56 time=33.670 ms
64 bytes from 4.2.2.2: icmp_seq=98 ttl=56 time=24.716 ms
64 bytes from 4.2.2.2: icmp_seq=99 ttl=56 time=32.956 ms

--- 4.2.2.2 ping statistics ---
100 packets transmitted, 100 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 12.441/28.711/79.932/14.109 ms

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK