Finding the most "recent" file in your S3 Bucket

Use the S3** ls **command to list the contents of your bucket.

Use sed to specify a break (of a space).  Print “the last column” using awk.

Pipe the output to tail -1 (printing the last line, of the column).

Store the result in a LAST_FILE environment variable:

**`LAST_FILE=$(aws s3 ls s3:``//bucket_name | sed 's/|/ /' | awk '{print $4}'|tail -1)`**

Author | Miles Davenport

Career programmer, who designs, assembles, fixes, and supports customers, software and systems.