나는 curl 문의 결과를 탐색 한 다음 반환 된 각 URL을 삭제하려고합니다.Bash 컬 탐색 결과 검색
{
"results" : [ {
"uri" : "URL/api/storage/generic-sgca/Lastest_Deploy.tar",
"created" : "2017-09-14T11:59:14.483-06:00"
}]
이 같은 50 개 이상의 라인이 있습니다 다음 반환
#!/bin/bash
declare -i Current_Date
declare -i Three_Months_Ago
Current_Date=($(date +%s%N)/1000000)
Three_Months_Ago=(${Current_Date}-7889238000)
curl -Username:Password "URL/api/search/dates?dateFields=created&from=${Three_Months_Ago}&today&repos=generic-sgca"
. 이제 "-X DELETE"curl 명령을 실행하여 반환 된 각 URL을 삭제할 수 있기를 바랍니다. 예 :
URL=curl -Username:Password "URL/api/search/dates?dateFields=created&from=${Three_Months_Ago}&today&repos=generic-sgca"
curl -Username:Password -X DELETE ${URL}
또는 이와 비슷한 것입니다. 이것을 어떻게 할 수 있습니까?
편집 :
나는 이것을 시도하고 작동하지 않는 것 :
#!/bin/bash
declare -i Current_Date
declare -i Three_Months_Ago
Current_Date=($(date +%s%N)/1000000)
Three_Months_Ago=(${Current_Date}-7889238000)
while read -r uri; do
curl -Username:Password -X DELETE "$uri"
done < <(
curl -Username:Password "URL/api/search/dates?dateFields=created&from=${Three_Months_Ago}&today&repos=generic-sgca" | # get the list of uris
grep -o "uri" | # filter out everything else
tr -d ',' | # remove commas
awk '{print $3}' # print just the uri
)
내가 수익이 얻을 :
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3225 0 3225 0 0 3225 0 --:--:-- --:--:-- --:--:-- 15140
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
curl: (3) <url> malformed
'echo curl -Username : Password -X DELETE "$ URI로 변경하여 URI가 어떻게 보이는지 확인하십시오. – shellter