Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have to delete all directories in a path, which are older than a specified date except some of them, in bash.
I know the names of the directories which shouldn't be deleted.
Use find. Here's an example which should work at least on FreeBSD:
find
find . -type d -not -newerct 'x days ago' -not -name dir1 -not -name dir2 -delete