Checking if a file is in a S3 bucket using the s3cmd

前端 未结 4 1025
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 23:37

I having a program that successfully uploads all of the files that I need. I have new files everyday that I need to upload. After I have uploaded the files I no longer need

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-03 23:43

    In the newer version of AWS CLI, you can use the following code to detect the existence of a file or directory

    count=$(aws s3 ls $path | wc -l)
    if [ $count -gt 0 ]
    then
      (>&2 echo "$path already exists!")
      return
    fi
    

提交回复
热议问题