Issue
I'm trying to create a command that would download the latest .gz file and install on my container in Dockerfile. I came up with this but I can't seem to get it working.
curl -s https://api.github.com/repos/fullstorydev/grpcurl/releases/latest | grep 'linux_arm64.tar.gz' | cut -d : -f 2,3 | tr -d \" | wget -qi - | sudo tar -C /usr/local/bin -xz;
I always get this error
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Solution
Like this:
file=$(
curl -s https://api.github.com/repos/fullstorydev/grpcurl/releases/latest |
jq -r '.assets | .[] | select(.browser_download_url | contains("linux_arm64")) .browser_download_url'
)
wget -O- "$file" | tar zxvf - | sudo tee /usr/local/bin/grpcurl
See https://github.com/stedolan/jq
Answered By - Gilles Quénot Answer Checked By - Robin (WPSolving Admin)