Sunday 9 May 2021

Jq: Processing wget command output

Just like how you are piping json data from echo command, from a file, you can even extract the ‘wget’ command output using jq tool.

 

Example 1: Get name of github project.

$wget -cq https://api.github.com/repos/harikrishna553/springboot -O - | jq '.name'
"springboot"

 

Example 2: get url of github project.

$wget -cq https://api.github.com/repos/harikrishna553/springboot -O - | jq '.html_url'
"https://github.com/harikrishna553/springboot"

 

Example 3: Get name, url, size and full name of the github project.

$wget -cq https://api.github.com/repos/harikrishna553/springboot -O - | jq '.name, .html_url, .size, .full_name'
"springboot"
"https://github.com/harikrishna553/springboot"
520
"harikrishna553/springboot"

 

How to install wget?

Step 1: Install brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

Step 2: Install wget

brew install wget

 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment