0

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.

4

1 回答 1

2

Use find. Here's an example which should work at least on FreeBSD:

find . -type d -not -newerct 'x days ago' -not -name dir1 -not -name dir2 -delete
于 2011-01-25T14:24:07.820 回答