AWS S3 ListBucketResult pagination without authentication?
#!/bin/sh# setting max-keys higher than 1000 is not effectives3url=http://mr2011.s3-ap-southeast-1.amazonaws.com?max-keys=1000s3ns=http://s3.amazonaws.com/doc/2006-03-01/i=0s3get=$s3urlwhile :; do curl -s $s3get > "listing$i.xml" nextkey=$(xml sel -T -N "w=$s3ns" -t \ --if '/w:ListBucketResult/w:IsTruncated="true"' \ -v 'str:encode-uri(/w:ListBucketResult/w:Contents[last()]/w:Key, true())' \ -b -n "listing$i.xml") # -b -n adds a newline to the result unconditionally, # this avoids the "no XPaths matched" message; $() drops newlines. if [ -n "$nextkey" ] ; then s3get=$s3url"&marker=$nextkey" i=$((i+1)) else break fidone