Web lists-archives.com

Re: get my ip address

On 16/02/2019 14.28, David Wright wrote:
On Sat 16 Feb 2019 at 11:10:32 (+0900), John Crawley wrote:
On 16/02/2019 08.54, David Wright wrote:
On Fri 15 Feb 2019 at 22:04:42 (+0000), Darac Marjal wrote:
If you're going to recommend parsing `ip`, the -j option may be more
amenable to scripting. (JSON output)
(Sorry if I was expected to explicitly write "shell scripting".)
… I don't think that JSON would be any help: rather, the opposite.

Though a call to jq makes parsing json very easy for shell scripts.

I'm not sure I understand why you'd ask ip to write JSON, and then
post-process it with jq to filter it to different JSON, and then
parse it in a shell, rather than just parsing something as simple as
the oneline format using the tools that every system has installed

jq can pull out the exact element of the json that you want, making further shell parsing unnecessary.
Totally unrelated example, (Adobe flash player downloads)
this query:
curl -s "https://get.adobe.com/flashplayer/webservices/json/?platform_type=Linux&platform_arch=x86-32&browser_dist=Chrome"; | jq -r '.[0].download_url'