shell循環ping ip的寫法


#!/bin/bash
 for i in `seq 1 20`
  do
 if ping -w 2 -c 1 192.168.43.$i | grep "100%" > /dev/null;then
  echo "192.168.43.$i is not reachable"
  else
 echo "192.168.43.$i is reachable"
 fi
  done

  

-w 2 表示等待時間為2秒。-c 1表示ping 1次

 

[root@centos6 ~]# ./ping.sh
192.168.43.1 is not reachable
192.168.43.2 is reachable
192.168.43.3 is not reachable
192.168.43.4 is not reachable
192.168.43.5 is not reachable

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM