0

So I was trying to use wget to download, but every time I try, it reterned a 404 because there's a %0B added:
--2022-01-29 17:42:34-- https://github.com/sebanc/brunch/releases/download/r97-stable-20220121/brunch_r97_stable_20220121.tar.gz%0D

Here's my code:
linkdl=$(curl -s https://api.github.com/repos/sebanc/brunch/releases/latest | grep -E 'browser_download_url' | grep brunch | cut -d '"' -f 4 | tr -d '\r')
wget $linkdl

OctonalXX
  • 49
  • 9

2 Answers2

2

I just took a look at the output from the cURL command, and I can see that it's outputting JSON.

I makes sense to properly parse JSON, you can do so with the command line tool jq:

$ curl -s https://api.github.com/repos/sebanc/brunch/releases/latest | jq -r '.assets[].browser_download_url'
https://github.com/sebanc/brunch/releases/download/r97-stable-20220121/brunch_r97_stable_20220121.tar.gz

The command above will output a list of URL's to all assets, which you can then iterate and download with cURL or wget:

curl -s 'https://api.github.com/repos/sebanc/brunch/releases/latest' |
jq -r '.assets[].browser_download_url' |
while IFS= read url
do
  wget "$url"
done
Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
0

I just found out I used windows format, I changed it and no errors.

OctonalXX
  • 49
  • 9