我正在运行以下curl命令:
results=$(curl -USERNAME:PASSWORD "URL/search/dates?dateFields=created&from=${Three_Months_Ago}&today&repos=generic-sgca")
echo "$results"
我得到的回报是:
"results" : [ {
"uri" : "URL/api/storage/generic-sgca/Lastest_Deploy.tar",
"created" : "2017-09-14T11:59:14.483-06:00"
}, {
"uri" : "URL/api/storage/generic-sgca/Installer-Deploy-0.0.5/SignalStudioPro-Alpha-1-linux-x64-installer.run",
"created" : "2017-09-14T20:11:37.733-06:00"
}
它似乎实际上并未将卷曲结果存储为数组。我希望能够将每个“uri”存储为变量,并使用“-X DELETE”命令删除每个文件。如何单独获取“uri”行,删除“创建”选项。
EDIT:
我使用了以下命令:
results=$(curl -username:password "URL/api/search/dates?dateFields=created&from=${Three_Months_Ago}&today&repos=generic-sgca" | jq -r '.results[].uri')
echo "$results"
我得到了这样的回报:
URL/api/storage/generic-sgca/Lastest_Deploy.tar
URL/api/storage/generic-sgca/Installer-Deploy-0.0.5/SignalStudioPro-Alpha-1-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-0.0.5/SignalStudioPro-Alpha-1-windows-installer.exe
URL/api/storage/generic-sgca/Installer-Deploy-0.0.99/SignalStudioPro-Alpha-1-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-0.0.99/SignalStudioPro-Alpha-1-windows-installer.exe
URL/api/storage/generic-sgca/Installer-Deploy-0.2.0/SignalStudioPro-Alpha-2-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-0.2.0/SignalStudioPro-Alpha-2-windows-installer.exe
URL/api/storage/generic-sgca/Installer-Deploy-100.0.0/SignalStudioPro-Alpha-2-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-100.0.0/SignalStudioPro-Alpha-2-windows-installer.exe
URL/api/storage/generic-sgca/Installer-Deploy-101.0.0/SignalStudioPro-Alpha-2-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-101.0.0/SignalStudioPro-Alpha-2-windows-installer.exe
URL/api/storage/generic-sgca/Installer-Deploy-99.9.9/SignalStudioPro-Alpha-2-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-99.9.9/SignalStudioPro-Alpha-2-windows-installer.exe
URL/api/storage/generic-sgca/Installer-Deploy-99.9.91/SignalStudioPro-Alpha-2-linux-x64-installer.run
URL/api/storage/generic-sgca/Installer-Deploy-99.9.91/SignalStudioPro-Alpha-2-windows-installer.exe
现在我想运行curl -X DELETE 命令来从我的Artifactory 页面中删除每个URL。命令是:
curl username:password -X DELETE "URL FROM ABOVE"
但我不知道如何将每一行存储为单独的变量,以便我可以删除每一行。