Finding directories older than 5 days

Hello,

Motive: Search all directories which are older than 5 days.

Example: consider following directory structure:
abc/dir1 abc/dir1/dir abc/dir2 abc/dir3 abc/dir3/temp
Suppose dir1 and dir3 are 5 days older. Then I am looking for a command which lists abc/dir1 and abic/dir3 only so that I can delete them.

Command I Used: find /my/path/ -type d -ctime +5 -exec rm {} \;

Issue: This command is not working. Please help.

Hi,

Please post the your output after running your command.

These are the directories I have:

drwxrwxrwx  3 jgupta2 other 4096 Apr 19 16:43 as
drwxr-xr-x  2 jgupta2 other 4096 Apr 26 16:48 scripts

The command is giving no output:

$ find . -type d -ctime +5
$

for the first post wherein you were trying to delete, the code should be as below.

find /my/path/ -type d �ctime +5 �exec rm -r {} \;

rm is used to delete a file. For a directory structure having some contents, you should use rm -r
for the second post, use the -print option at the end to display the result to the screen.

find . -type d -ctime +5 -print

Perfect, following serves my purpose of displaying the directories

find . -type d -mtime +5 -maxdepth 1 -print

And following deletes them:

find . -type d -mtime +5 -maxdepth 1 -exec rm -r {} \;

Many thanks for your help.