I\'m trying to use just the IP address (inet) as a parameter in a script I wrote.
Is there an easy way in a unix terminal to get just the IP address, rather than loo
These two ways worked for me:
To get IP address of your interface eth0. Replace eth0 in the below example with your interface name.
ifconfig eth0 | grep -w "inet" | tr -s " " | cut -f3 -d" "
Using hostname: This will give you the inet i.e. IPAddress of your etho. using -I will give you inet value of all the interfaces whereever this value is present.
hostname -i