pikesaku’s blog

個人的な勉強メモです。記載内容について一切の責任は持ちません。

AWS CLI S3コマンドinclude・excludeメモ

ポイント

・順番に評価され、より後で評価されたもので決定。この点を考慮しinclude・exclude両方指定した方が直感的かも。
 例1) --exclude "*" --include "*.txt" →txt拡張子だけがマッチ
 例2) --include "*.txt" --exclude "*" →全てマッチ
・*は全てにマッチ
・?は1文字にマッチ
・[文字集合]、[^文字集合]で文字クラス(?)的な指定が可能
 

aws s3 helpより抜粋

   Use of Exclude and Include Filters
       Currently, there is no support for the use of UNIX style wildcards in a
       command's  path  arguments.   However,  most  commands  have  --exclude
       "<value>" and --include  "<value>"  parameters  that  can  achieve  the
       desired  result.   These  parameters perform pattern matching to either
       exclude or include a particular file or object.  The following  pattern
       symbols are supported.

          o *: Matches everything

          o ?: Matches any single character

          o [sequence]: Matches any character in sequence

          o [!sequence]: Matches any character not in sequence

       Any  number of these parameters can be passed to a command.  You can do
       this by providing an --exclude or --include  argument  multiple  times,
       e.g.   --include  "*.txt"  --include  "*.png".  When there are multiple
       filters, the rule is the filters that appear later in the command  take
       precedence  over filters that appear earlier in the command.  For exam-
       ple, if the filter parameters passed to the command were

          --exclude "*" --include "*.txt"

       All files will be excluded from the command  except  for  files  ending
       with  .txt   However, if the order of the filter parameters was changed
       to

          --include "*.txt" --exclude "*"

       All files will be excluded from the command.