Use regex to select only certain files via s3cmd

Recently I wanted to download only a small subset of thousands of files from an S3 “folder.”

The s3cmd docs were lacking with regard to how to select only a subset.

This is how I downloaded only log files from 11PM:
s3cmd get --recursive --rinclude ".*2014-10-28-23.*" --rexclude ".*" s3://my-bucket-of-logs/folder/2014-10-28/

Note that I used both rinclude and rexclude. If you only use rinclude (or include), it won’t restrict only to what you specified, but it will ensure what you specified is taken. So you have to exclude everything first (--rexclude ".*"), THEN include only what you want (--rinclude ".*2014-10-28-23.*")