but what if you want to get the ip from console and save this into a text file?, this is usefull if later you wants to send this file to some email. If your need is this, so, just follow the next steps tested in Linux Mint.
first try the command via console and look you get the right answer:
$ curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' > mi_ip
this will copy the Public IP to mi_ip file, just check your file and see the result:
$ nano mi_ip
you can add the command to crontab in order to periodically send you an email with the ip result. For this create a shell script:
$ nano mi_ip.sh
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' $
cat ~/mi_ip.txt | mail -s "My IP address is:" put_your_email_here
save and exit nano. Now configure your crontab jobs:
$ crontab -e
put this at the bottom of the file:
#Send mi public ip to my email
save and exit. With the option @daily the scritp would be executed each day at midnight. That's all!