[ale] Bash script

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


> Boris Borisov via Ale wrote on 2025-04-12 14:42:
> 
>> I'm trying to list all files on SSD disk (Windows) and to find the
>> oldest file and the newest file.

Ron via Ale wrote on 2025-04-12 15:26:

> Here's something that can be get the newest and oldest files:

It may have been incorrect to focus on "files" per the question, since a
directory's info might be relevant.


Modifying the `-type f` to `-type d` to get only directories, or just 
removing it to get both, should give what you're looking for.

Also, adding -d to `ls` will ensure directories and files will sort
together and *must* be used if directories are included.


Revised version which may need further tweaks depending on mount point:

> ## Newest:
 >
> find $mount_point -exec ls -dltrA {} \+  | tail -n 1

> 
> ## Oldest:
 >
> find $mount_point -type f -exec ls -dltA {} \+  | tail -n 1


More information about the Ale mailing list