Question: How to delete all the files that are older than the latest modified file/s
The following one line command will find and delete all files except the latest 6 - but I am unable to figure out how to delete all files that are older than the latest file/s (there can be several latest files) -
ls -t | tail -n +6 | xargs rm --
Details: I would like to delete all the files that are older than the latest modified file date. It doesn't matter how many days it is older - as long as it is older than latest modified file, it needs to be deleted (100 days or 1000 days or 1 day or even 1 min older than the latest modified file).
Dir-
File 1 6/10/2019 9:40am
File 2 6/10/2019 9:37am
File 3 6/10/2019 9:40am
File 4 2/12/2019 12:39pm
File 5 7/01/2002 11:38pm
From this dir, after running the command, I should be able to only see File 1 and 3, all other files should be deleted regardless of how old those file are when compared the latest modified file/s.