Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Print out IP address script

I need to make a script that gets my public IP address from a website and prints it out.
#!/bin/bash
wget ://www.ipchicken.com/

grep


I don't know where to go from here.

Please help
by

1 Answer

Bharatgxwzm
What you're trying to do is fragile; it depends on the format of the HTML document returned by ipchicken, and that can change without warning. This currently works for me, your mileage may vary:
$ wget //www.ipchicken.com/ -qO - | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
108.27.105.76

Login / Signup to Answer the Question.