Linux Get IP Address
get_linux_ip_info.sh
#!/bin/bash#/Tell the consumer that the user of this program obtains the IP address from the ipconfig commandEcho "The program is the IP address obtained from ifconfig in the command:"#2, prompt the user, enter the name of the device that will be queried read-P"Please enter the name of the device you want to query IP: (eth0/eth1/eth2/help):"Dev Case${dev}inch " Help") Echo "If you do not know your computer device number, you can view it by command/etc/udev/rules.d/70-persistent-net.rules. "Exit1 ;; "") Echo "Please enter content, such as Eth0/eth1/eth2/help"Exit1 ;; "eth0") ifconfigeth0 |grep 'inet'|sedS/^.*ADDR://g | sed s/bcast.*$//gExit1 ;; "eth1") ifconfigeth1 |grep 'inet'|sedS/^.*ADDR://g | sed s/bcast.*$//gExit1 ;; "eth2") ifconfigeth2 |grep 'inet'|sedS/^.*ADDR://g |sed s/bcast.*$//g ;; *) Echo "Please enter the correct content! "Exit1 ;; ECAC
get_linux_ip_info.sh Get IP Address