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
Command ifconfig is deprected and you should use ip command on Linux.
Also ip a will give you scope on the same line as IP so it's easier to use.
This command will show you your global (external) IP:
ip a | grep "scope global" | grep -Po '(?<=inet )[\d.]+'
All IPv4 (also 127.0.0.1):
ip a | grep "scope" | grep -Po '(?<=inet )[\d.]+'
All IPv6 (also ::1):
ip a | grep "scope" | grep -Po '(?<=inet6 )[\da-z:]+'