I have a directory, with thousands of files.
I need to sort the files in descending order of creation date (to make sure that the newest files wont be deleted), and start summing the size of these files until the summation reaches a certain limit (example 10GB).
Once that is reached, I need to be able to delete all the files (that are already sorted in descending order), that come after those 10GB of files.
So, after the operation, the contents of my directory should not exceed 10GB in total size, but the newest files must remain.
I need to be able to accomplish this without the usage of GAWK since I don't have GNU system.
Is this doable with the find
command only?
So i need to write a shell script, that allows me to accomplish the above.
I am trying to write some code with awk command, but am not able to reach what i need.
– Charbel Sep 17 '21 at 13:08