You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can tell, gsutil ls (v5.25) does not allow for sorting by file/directory timestamps. I could use something like the following to accomplish this:
# List all files in a GCS bucket
files=$(gsutil ls gs://your-bucket-name/*)# Initialize an empty associative array to hold file creation timesdeclare -A file_dates
# Loop through each file to get its creation dateforfilein$files;do
creation_date=$(gsutil stat $file| grep "Creation time:"| awk -F: '{print $2 $3 $4}')
file_dates["$file"]=$creation_datedone# Sort files by creation date and printforfilein$(echo "${!file_dates[@]}"| tr '''\n'| sort -k3);doecho"$file - ${file_dates[$file]}"done
...but it would be great to have this feature built directly into gsutil
The text was updated successfully, but these errors were encountered:
As far as I can tell,
gsutil ls
(v5.25) does not allow for sorting by file/directory timestamps. I could use something like the following to accomplish this:...but it would be great to have this feature built directly into
gsutil
The text was updated successfully, but these errors were encountered: