Linux obtains the native ip address method through Shell.

  

Get the local IP address method through Shell, directly on the code:
IP=`ifconfig |  Grep 'inet addr:' |  Grep -v '127.0.0.1' |  Cut -d: -f2 |  Awk '{ print $1}'`;echo $IP;

If you want to get the first IP address, you can add the parameter -m 1 to grep ‘inet addr:’

Copyright © Windows knowledge All Rights Reserved