测试IP的BASH脚本

有没有一种优雅的方法来测试BASH脚本中的IP地址?我可以使用sed / awk来做ifconfig和缩小IP,但我认为有一个更简单的解决方案.

当我在我的Intranet中时,我的应用程序基本上使用SSH / SCP脚本,而我不是.所以,我想要这种类型的流程

if IP=192.168.1.1
      then do this
 else
      then do that
你可以根据自己的需要修改一些相当简单的东西:
ip addr show dev eth0 | fgrep -q 'inet 192.168.1.1'
if [ $? -eq 0 ]; then
   echo 'IP found'
else
   echo 'IP not found'
fi

编辑:忘了fgrep

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...