Skip to content
Advertisement

Shell script: Using own IP adresss as variable

I have to write a shell script which initializes docker swarm.

I need to pass the own IP address as argument:

JavaScript

How can I do this dynamically? I know the ifconfig command, which allows me to see the IP, but I can not pass the whole thing as variable. It should look like this

JavaScript

Advertisement

Answer

The following command will return your public ip address

JavaScript

Please try the following

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement