How can I construct my grep command on zsh to return a specific value?

Solution 1:

grep isn't well suited for data scrapping, you are better of with sed in such cases.

curl -sG 'https://marketplace.visualstudio.com/items?itemName=HCLTechnologies.hclappscancodesweep' \
    | sed -Ene 's/.*\"install\",\"value\":([0-9\.]+).*/\1/p'

The first part of the substition matches only once in the HTML file so there isn't even a need to select the correct line first.

To get the number without the decimal point use

curl -sG 'https://marketplace.visualstudio.com/items?itemName=HCLTechnologies.hclappscancodesweep' \
    | sed -Ene 's/.*\"install\",\"value\":([0-9]+).*/\1/p'