I am using the aws cli to list the files in an s3 bucket using the following command (documentation):
aws s3 ls s3://mybucket --recursive --human-readable --
I would suggest not depending on the spacing and fetching the 4th field.
You technically want the last field regardless of which position it was in.
So it's safer to use rev to your advantage...
rev reverses the string input char by char
so when you pipe the aws s3 ls out put to rev you have everything reversed, including the positions of the fields, so the last field always becomes the first field.
Instead of figuring out where the last field would be, you just rev, get first, then rev again because the characters in the field would be in reverse as well. (e.g. 2013-09-02 21:32:57 23 Bytes foo/bar/.baz/a becomes a/zab./rab/oof setyB 32 75:23:12 20-90-3102)
then cut -d" " -f1would retrieve the first fielda/zab./rab/oofrev
then again to getfoo/bar/.baz/a`
aws s3 ls s3://mybucket --recursive | rev | cut -d" " -f1 | rev