I have a path where there will be build directories copied, so i need to keep only latest 3 directories and delete others, not by date but with the latest build number.
If i have the following directories in the path /tmp
1.1.0000-021, 1.1.0000-005, 1.1.0000-018, 1.1.0000-004
I should be deleting 1.1.0000-004 directory in /tmp path as its the oldest directory.
I was trying with rm -rf /base/path -type d -ctime 4 , but this is based on latest file, not sure about getting oldest number to delete.