[ale] Bash script

Ron admin at bclug.ca
Sun Apr 13 00:28:13 EDT 2025


Bob Toxen via Ale wrote on 2025-04-12 18:57:

> The following seems to work for me but may fail if any files are larger
> than 999999999 bytes:
> 
>    ls -l --full-time | sort -k 6 | head -3 |tail -1
>    ls -l --full-time | sort -k 6 |  tail -1

You should test these...

Why the use of `head -3`?

Truncating everything after that, it gives the "total ####" line and 
*two* files.

Then, `tail -n 1` takes the *second* oldest file - whaaat?


Also, you need to test this on a folder that has sub-folders, because 
this will not work then.

It does not traverse sub-directories which is kinda important when 
looking across an *entire SSD*.



The issue with files of size > 999999999 bytes might be fixable with `ls 
--human-readable`, but my `find` is much better with a minor tweak.


Also, --full-time implies -l, so that could be shortened. But I'd write 
it the same way you did, since it's good to be explicit.


F.



More information about the Ale mailing list