#instead of ls, use sync in dryrun mode aws s3 sync s3://bucket-name . --exclude "*" --include "folder*/*file*.txt" --dryrun # important
aws s3 ls s3://my-bucket/folder/ | grep myfile