Horje
grab ipaddress in variable linux Code Example
grab ipaddress in variable linux
# The original web page offers a few alternatives. This one seems to be easy to understand, replicate and customize
# It will grab the first non 'localhost' and non 'ipv6' address
IP=$(ifconfig | grep -e 'inet' | grep -v 'inet6' | grep -v '127.0.0.1' | head -n 1 | awk '{print $2}')


# However, sometime it returns a 192.168.x.x type of address.
# In which case, this will return the public IP
IP=$(ip route get 8.8.8.8 | awk '{print $3}')




Shell

Related
ip address in variable Code Example ip address in variable Code Example
ubuntu show memory usage Code Example ubuntu show memory usage Code Example
node upgrade mac os x Code Example node upgrade mac os x Code Example
install scss in react js Code Example install scss in react js Code Example
name of exe on ubuntu 20.04 terminal Code Example name of exe on ubuntu 20.04 terminal Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13