pikesaku’s blog


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


 例1) --exclude "*" --include "*.txt" →txt拡張子だけがマッチ
 例2) --include "*.txt" --exclude "*" →全てマッチ

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

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

       All files will be excluded from the command.