#! /bin/bash
key=LIVDSRZULELA #key provided by tenor
url="https://g.tenor.com/v1/search?q=$1&key=$key&limit=$2"
#search key and total results will be given by command arguments
js=$(curl $url) # this have whole json result from tenor
res=$(echo $js | jq '.results[].media[].gif.url') # res contains the url of the gif that we searched
cd $HOME/Desktop/Me/gifs
echo $res # outputs correct URL
curl -O $res # this is giving error
問題是我無法卷曲 res vaiable,因為它顯示了錯誤/非法格式的錯誤
uj5u.com熱心網友回復:
添加-r到 jq 命令(用于原始輸出)。您的代碼只能處理limit=1以下對我有用
key=LIVDSRZULELA #key provided by tenor
url="https://g.tenor.com/v1/search?q=$1&key=$key&limit=$2"
#search key and total results will be given by command arguments
url2=$(curl $url | jq -r '.results[].media[].gif.url') # this have whole json result from tenor
curl "$url2"
testit cake 1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4301 0 4301 0 0 37504 0 --:--:-- --:--:-- --:--:-- 40196
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/448110.html
