I need help for a script that will remove all but the newest of these types of directories.
I know I need rm.
01-16-18-img
2018-01-26-11-img
I need help for a script that will remove all but the newest of these types of directories.
I know I need rm.
01-16-18-img
2018-01-26-11-img
take a look at the first solution …
Looks like it would delete most of what I DON’T want deleted.
andyk_/media/andy/MAXTOR_SDB2$ find -type d ! -wholename $(find -type d -printf ‘%T+ %p\n’ | sort -r | head -1 | cut -d" " -f2) ! -wholename “.”
./2018-01-26-11-img
./Clonezilla_Images
./.Trash-1000
./.Trash-1000/info
./.Trash-1000/expunged
./.Trash-1000/files
./01-16-18-img
./01_06_2018img
./SDB2_Mountpoint
./lost+found
This looks more complicated, but should be doable.