zoukankan      html  css  js  c++  java
  • get_linux_ip_info.sh 获取ip地址

    linux 获取ip地址

    get_linux_ip_info.sh

    #!/bin/bash
    #/告诉使用者,这程序的用户是从ipconfig 命令中获取IP地址
    echo "该程序是从命令中ifconfig中获取的IP地址:"
    #2、提示使用者,输入将要查询设备的名字
    read -p "请输入想要查询IP的设备名字:(eth0/eth1/eth2/HELP):" Dev 
    case ${Dev} in
        "HELP")
        echo "如果不知道您电脑设备号,可以通过命令/etc/udev/rules.d/70-persistent-net.rules 查看。"
        exit 1
        ;;
        "")
        echo "请输入内容,如eth0/eth1/eth2/HELP"
        exit 1
        ;;
        "eth0")
        ifconfig eth0 |grep 'inet' |awk 'NR==1{print}'| sed s/^.*addr://g | sed s/Bcast.*$//g
        exit 1
        ;;
        "eth1")
        ifconfig eth1 |grep 'inet' |awk 'NR==1{print}'| sed s/^.*addr://g | sed s/Bcast.*$//g
        exit 1
        ;;
        "eth2")
        ifconfig eth2 |grep 'inet' |awk 'NR==1{print}'| sed s/^.*addr://g |sed s/Bcast.*$//g
        ;;
        *)
        echo "请输入正确的内容!"
        exit 1
        ;;
    ecac
  • 相关阅读:
    软件工程第1次阅读作业
    软件工程第0次作业
    OO第四次博客
    OO第三次总结
    OO第二次总结
    OO第一次总结
    提问回顾与个人总结
    结对项目:最长单词链
    第一次阅读作业
    第四次博客
  • 原文地址:https://www.cnblogs.com/sxwen/p/7953627.html
Copyright © 2011-2022 走看看