Hacker News new | ask | show | jobs
by macote 694 days ago
This is how I use it in my bash script:

  current_ip=$(curl -s -X GET https://1.1.1.1/cdn-cgi/trace | grep -Po "(?<=ip=)(.*)")
1 comments

I find awk more clear for this kind of job. You can replace

  grep -Po "(?<=ip=)(.*)"
with

  awk -F= '$1 == "ip" { print $2 }'
Thanks for that, I agree.