+9 votes
1 view
in AWS by (1.5k points)

I am unable to copy some files from a S3 bucket in AWS CLI

Adding * to the path is not helping:

aws s3 cp s3://personalfiles/file* 

Please help

1 Answer

+11 votes
by (10.6k points)
edited by
  • You can use 3 high-level S3 commands that are inclusive, exclusive and recursive.
  • --include and --exclude are used to specify rules that filter the objects or files to be copied during the sync operation or if they have to be deleted 
  • Using recursive command on a file or directory, the command walks the directory tree including all the sub-directories


--exclude "*" --include "*.txt"  \\\All files will be excluded from the command except for files ending with .txt

--include "*.txt" --exclude "*"  \\\All files will be excluded from the comand


aws s3 cp /tmp/foo/ s3://bucketfiles/ --recursive --exclude "*" --include "*.jpg"

  • Try the coded provided below:

aws s3 cp s3://personalfiles/ . --recursive --exclude "*" --include "file*”

Learn more about AWS by going through AWS course and master this trending technology.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !