feature request: `gsutil ls` => sort by timestamp
nick-youngblut opened this issue · 1 comments
nick-youngblut commented
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 times
declare -A file_dates
# Loop through each file to get its creation date
for file in $files; do
creation_date=$(gsutil stat $file | grep "Creation time:" | awk -F: '{print $2 $3 $4}')
file_dates["$file"]=$creation_date
done
# Sort files by creation date and print
for file in $(echo "${!file_dates[@]}" | tr ' ' '\n' | sort -k3); do
echo "$file - ${file_dates[$file]}"
done
...but it would be great to have this feature built directly into gsutil
RahulDubey391 commented
Hi @nick-youngblut , I would like to work on this issue. Can you please assign it to me?