Bash scripting curl request with twist

后端 未结 1 1581
忘了有多久
忘了有多久 2021-01-24 13:19

I\'m attempting to pull in data from an API using curl, and have the majority of the script done, but need some assistance. The API has results in multiple pages I need to retri

相关标签:
1条回答
  • 2021-01-24 13:55

    Take the end test out of the for header, and test for it inside the loop. You can then use break to end the loop.

    for ((i=1; ; i++)); do
        contents=$(curl -H "Authorization: Token insertlongtokenhere" -H "Content-Type: application/json" https://api.app.secunia.com/api/tickets/?page=$i)
        echo "$contents"
        if [[ $contents =~ 'next":null' ]]
        then break
        fi
    done
    
    0 讨论(0)
提交回复
热议问题