LoginSignup
0
0

More than 1 year has passed since last update.

S3に存在しないファイルを見つけ出すコマンドを書こう

Last updated at Posted at 2023-03-17

課題

手元にファイル名100個があります。
100個のファイルの中にS3に存在するファイルと存在しないファイルを見つけ出したい。

コマンドの例

aws s3 ls s3://<bucket>/<path1> >> exist.txt || echo <path1> >> not_exist.txt
aws s3 ls s3://<bucket>/<path2> >> exist.txt || echo <path2> >> not_exist.txt
aws s3 ls s3://<bucket>/<path3> >> exist.txt || echo <path3> >> not_exist.txt
...

原理

ファイルが存在する場合||前半のコマンドのみ実行され、
ファイルが存在しない場合||後半のコマンドが実行され、
これて、存在するファイルと存在しないファイルが両方ファイルに出力される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0