Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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}')
Comment

PREVIOUS NEXT
Code Example
Shell :: check storage in ubuntu terminal 
Shell :: linux apt pcap 
Shell :: update yarn version 
Shell :: cp folder ubuntu include git 
Shell :: git mainstages 
Shell :: linux typing hebrew 
Shell :: update pycocotools 
Shell :: inodes full 100% 
Shell :: github gitattributes ignore files for statistics 
Shell :: ubuntu 20 install lib32ncurses5 
Shell :: ubuntu disable ssh 
Shell :: command to upgrade upgradable packages on Ubuntu 
Shell :: add desktop entry ubuntu 
Shell :: debian all services 
Shell :: finding mac address on ubuntu 
Shell :: return to bash from zsh 
Shell :: wsl convert to wsl2 
Shell :: remove local changes git 
Shell :: microstack change horizon port 
Shell :: sqlite3 attempt to write a readonly database 
Shell :: ubuntu watch log file command 
Shell :: install antigen mac 
Shell :: install rust ubuntu 20 
Shell :: gcloud list current CLI Configuration 
Shell :: git log format online 
Shell :: tar extract to path 
Shell :: linux windows use ssh with github 
Shell :: git pasar de https a ssh 
Shell :: debian uninstall package 
Shell :: check permissions for a folder in ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =