将cURL数据发送到多个URL

时间:2018-12-02 01:55:12

标签: bash curl

我的代码包含以下内容:

curl -k -X DELETE \
-H "X-Parse-Application-Id: staticid" \
-H "X-Parse-Master-Key: statickey" \
https://mystatic.url/dynamicvalue

我有一个URL列表:

https://mystatic.url/johndylan

https://mystatic.url/marypoppins

等,包含在tobedeleted.txt文件中,我想将自己的cURL代码修改为如下所示(我已经尝试过,但是没用:

curl -k -X DELETE \
-H "X-Parse-Application-Id: staticid" \
-H "X-Parse-Master-Key: statickey" \
> tobedeleted.txt

或类似这样的东西(我也尝试过,但是没有用)

curl -k -X DELETE \
-H "X-Parse-Application-Id: staticid" \
-H "X-Parse-Master-Key: statickey" \
https://mystatic.url/$tobedeleted.txt

请注意,我想针对文件的每一行每次都运行相同的cURL命令,所以我想我需要像foreach函数之类的东西,因为这是一个bash脚本。

1 个答案:

答案 0 :(得分:1)

您将想要这样的东西:

while read value
do

    curl -k -X DELETE \
    -H "X-Parse-Application-Id: staticid" \
    -H "X-Parse-Master-Key: statickey" \
    https://mystatic.url/$value

done < tobedeleted.txt