Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

ip address in variable

# 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 :: youtube-dl continue 
Shell :: split terminal horizontally ubuntu 20.04 
Shell :: how to install gatsby with typescript 
Shell :: bash unsquash specific files 
Shell :: journalctl tial 
Shell :: mate-polkit-bin for ubuntu 
Shell :: firefox hide password warning 
Shell :: ubuntu auditd show process activity by rules 
Shell :: Install OpenERP on Mac OS X 10.8 odoo 
Shell :: flake8 only 
Shell :: git rebase develop into feature 
Shell :: install svelte 
Shell :: What is the command to open a file from within Emacs? 
Shell :: linux remove folder 
Shell :: docker interactive shell 
Shell :: git get commit id 
Shell :: flutter license NoClassDefFoundError 
Shell :: push an existing github repository 
Shell :: notify once a job is completed 
Shell :: ls in mb mac 
Shell :: how to extract key and cert from pfx 
Shell :: apt show package url 
Shell :: docker purge all 
Shell :: verify elementary os iso image 
Shell :: undo git merge 
Shell :: Cria um dispositivo gerenciado de cores 
Shell :: how to setup git locally with ssh 
Shell :: Katie Leung 
Shell :: ver espacio en disco linux 
Shell :: git remove directory from tracking 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =