local_ip.sh 168 B

123456
  1. ip=`ifconfig 2>&1|grep 'inet addr'|grep -v '127.0.0.1'|awk 'NR==1 {print $2}'|awk -F ':' '{print $2}'`
  2. if [[ -z $ip ]]; then
  3. echo "127.0.0.1"
  4. else
  5. echo $ip
  6. fi