2012-07-24 144 views

回答

6

這很簡單,但取決於您希望檢查的複雜程度。假設你想刪除其文件名包含「富」每一個文本文件:

s3cmd --recursive ls s3://mybucket | 
    awk '{ print $4 }' | grep "*.txt" | grep "foo" | xargs s3cmd del 

如果你想要一個更復雜的檢查比grep的可以處理,只是前三個命令重定向到一個文件,然後手動編輯文件或者使用或awkperl或任何你喜歡的工具,然後cat輸出爲s3cmd(取決於檢查,你可以做到這一切與管道,太):

s3cmd --recursive ls s3://mybucket | awk '{ print $4 }' | grep "*.txt" > /tmp/textfiles 
magic-command-to-check-filenames /tmp/textfiles 
cat /tmp/textfiles | xargs s3cmd del