Skip to Content

AWS S3 LS Sort By Date | How it works & how to use

AWS S3 LS Sort By Date | How it works & how to use

There are many commands out there for AWS s3.

There are also many command list cheat sheets available. However, some of those sheets don’t include some major commands, as the following shows:

AWS s3 ls with date

Cli command is as follows: -word=opt word: opt numb: 42 fork: false svar: bar tail: [].

It will appear with a -t-flag.

The date will be sorted by the t-flag.

First, you must open the terminal if it’s not open.

Then, you must navigate to the desired directory according to the sorted date with ls.

Then, issue the command syntax, and click to view the directory contents with Is by the date.

The following is an illustration.

ls sort command output by date and time

(OS X Daily, 2021)

AWS s3 ls with timestamp

Cli command with the timestamp will be as the following examples illustrate:

aws s3 ls


2013-07-11 17:08:50 mybucket
2013-07-24 14:55:44 mybucket2

The above examples are for the owner of my bucket and mybucket2.

The time zones are also shown above instead of UTC, and these times can change when the bucket policy is edited, for instance.

Other great examples are as follows, along with the modified URLs for privacy:

$ aws s3 ls s3://foo/bar 2020-04-26 05:26:32 6736 bar


$  aws s3 ls s3://foo/bar
2020-04-26 05:26:32 -07:00       6736 bar

Please note: There’s a -7 hour offset (Los Angeles time) shown in the example above to show the time zone.

AWS s3 ls without date

Cli command is: AWS s3 ls s3://myS3bucket –recursive –human-readable –summarize or aws s3 ls s3://mysS3bucket –recursive | awk ‘{print $4}’

For all s3 common prefixes and objects, the Is command is used to list them under all s3 buckets or a prefix.

This command doesn’t have the –no-paginate and –output.

Please note that AWS s3 Is is not enough, so there must be appropriate syntax.

Having said that, you can also use the other command as shown above.

Just omit the human-readable flag and the summarized flag to obtain an easier output to work with as shown above.

This is used to get the other syntax.

Other than that, you can add spaces to filenames by using the following syntax:

AWS s3 ls s3://mybucket –recursive | awk ‘{$1=$2=$3=””; print $0}’ | sed ‘s/^[ \t]*//’

AWS s3 ls sort by modified date

Cli command includes the -t flag and as follows: word=opt word: opt numb: 42 fork: false svar: bar tail: [], -l long listing flag, or ls -halt

The modified date will also be sorted by the t-flag as it is for the AWS s3 ls with the date.

The command output will be sorted by the last modified time and date.

For the best results, applying the -long listing flag and a few others may work.

Another great way to sort an Is output by the modified date, use the following: lt, -h for human readable sizes, and -a for displaying all dot prefixed files.

As shown above, Is -halt, is a flag to remember.

Also, the following shows the modified dates listed at the top.

ls sort command output by date and time

(OS X Daily, 2021)

AWS s3 ls sort by date descending

Cli command is used with a -r flag. It is used like this, ls -haltr.

So, to descend it, i.e, reverse it, you can use Is-haltr.

The modified time and date will be at the end of the ls command output.

That is the only difference. Everything else would remain the same.

This applies only to the terminal and the command line.

However, you can also use this method to sort the modified date variations or the last opened date in Finder.

For instance, you can sort by the last date opened in the Mac Finder ‘All My Files’.

This is an amazing tip that may be similarly applied to any other folder displayed in Finder on the Mac.

And just like the previous Is command, this command action will display the last time a file was modified or assessed.

As previously mentioned, many cheat sheets for the AWS s3 commands don’t have some of the major commands.

And thus, these commands mentioned above will go a long way to ensure you stay abreast of your important databases.