利用xargs实现多任务并发
利用xargs实现多任务并发
[4aiur@localhost Temp]$ echo 127.0.0.1 192.168.2.50 192.168.10.108 | xargs -n1 -P2 -I % ping -c 3 %
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.048 ms
PING 192.168.2.50 (192.168.2.50): 56 data bytes
64 bytes from 192.168.2.50: icmp_seq=0 ttl=64 time=0.026 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.091 ms
64 bytes from 192.168.2.50: icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from 192.168.2.50: icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.077 ms
--- 192.168.2.50 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.022/0.029/0.039/0.007 ms
--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.048/0.072/0.091/0.018 ms
PING 192.168.10.108 (192.168.10.108): 56 data bytes
64 bytes from 192.168.10.108: icmp_seq=0 ttl=63 time=6.244 ms
64 bytes from 192.168.10.108: icmp_seq=1 ttl=63 time=1.392 ms
64 bytes from 192.168.10.108: icmp_seq=2 ttl=63 time=1.062 ms
--- 192.168.10.108 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.062/2.899/6.244/2.369 ms
[4aiur@localhost Temp]$
使用xargs扫描同网段内存活的设备
[4aiur@localhost Temp]$ for ((x=1; x/dev/null | awk /ttl/'{print $4}'