While searching for a simple bash function that echoes my external IP address, I came across this post, which had the following example:
function ext-ip () { curl http://ipecho.net/plain; echo; }
I'm wondering how echo
works in this context; neither the curl
nor the echo
manpages were very helpful. Why does it echo the response body of the previous curl
command? And is there any advantage to doing in this way as opposed to, e.g. echo "$(curl -s http://ipecho.net/plain)"
? I'm only asking because the syntax of the latter seems more transparent/straightforward.