• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

recursive

AWS CLI S3 Recursive Copy

February 2, 2020

Here’s how to copy multiple files recursively using AWS CLI. The S3 cp command by default only copies a single file. To copy multiple files, you have to use the –recursive option along with –exclude and –include. In this example, we will exclude every file, but include only files with a json extension.

aws s3 cp /tmp/folder s3://bucket/folder \
  --recursive
  --exclude "*"
  --include "*.json"

aws s3 cp /tmp/folder s3://bucket/folder \ --recursive --exclude "*" --include "*.json"

The result:

upload: ./abc.json to s3://bucket/folder/abc.json    
upload: ./xyz.json to s3://bucket/folder/xyz.json

upload: ./abc.json to s3://bucket/folder/abc.json upload: ./xyz.json to s3://bucket/folder/xyz.json

Filed Under: Cloud Tagged With: aws, cp, exclude, files, include, multiple, recursive, s3

Diff Between Two Directories

September 2, 2019

Here’s how to get the differences between two directories using diff.

  • -q display only files when they differ
  • -r recursive to all sub-directories
diff -qr /directory-1 /directory-2

diff -qr /directory-1 /directory-2

Filed Under: Linux Tagged With: diff, directories, recursive

Copy Files Using Rsync

August 30, 2019

Here’s how to copy files from one directory to another.

rsync -arvz /dir1 /dir2 >> /tmp/rsync.log &

rsync -arvz /dir1 /dir2 >> /tmp/rsync.log &

Format: rsynch –options source destination

Options

  • -a archive mode
  • -v verbose
  • -p keep permissions
  • -z zipped during transfer
  • -r recursive

Filed Under: Linux Tagged With: archive, permissions, recursive, rsync, verbose, zipped

  • Home
  • About
  • Archives

Copyright © 2023