2021年3月19日星期五

if then statement in bash with curl not working for me

I want to create a check for when At times this api, does not return anything at all.

` myjson=$( curl -X GET "https://api.steampowered.com/ISteamApps/GetAppList/v2/" )

if ( ($myjson | jq '.applist, length' ) > 0);

then echo $myjson | jq -r '.' > myFile.json

else printf "don't do anything";

fi`

I want to check the length of .applist to make sure I don't overwrite the file if it is less 0 (0 would either mean the api is down or some other issue but most importantly it would not update my myFile.json )

if anyone could guide me at what exactly I am doing wrong in the if statement, it would be much appreciated.

https://stackoverflow.com/questions/66717349/if-then-statement-in-bash-with-curl-not-working-for-me March 20, 2021 at 09:06AM

没有评论:

发表评论