Deleting older files of a particular type

hi
This should be easy but i'm obviously missing something obvious. :slight_smile:
I'm looking to delete files from yesterday and older of extension .txt and there a range of subfolders with these files in them. The command runs but doesn't delete anything. SUSE 10.
find /testfolder -maxdepth 2 -type f -ctime +1 -name "*.txt" -exec rm -rf {} \; -ls
Elaine

are you getting any errors??

hi
No errors, just going back to prompt.
In the directory are files -
-rw-r--r-- 1 user nobody 115 2009-09-24 15:14 temp123.txt
-rw-r--r-- 1 user nobody 115 2009-09-23 14:20 temp124567.txt
-rw-r--r-- 1 root root 0 2009-09-23 08:50 testfile
so i'd hope the top 2 would go. and then one in folder -
called central -
-rwx------ 1 nobody nobody 152 2009-09-24 12:08 .htaccess
-rw-r--r-- 1 user nobody 115 2009-09-23 14:19 temp1234.txt
but not deleting the .htaccess files.
running as root.
Elaine

sorry for the confusion

  1. Without the rm command, does it displays both the files as you expect. ?
    $ find-command output without rm

  2. If it displays, does the rm used is the correct one ?! or you need to give absolute path of rm as /bin/rm ?
    $ which rm

Let us know the above clarifications.

1) The " -ls" at the end of the command will make it fail.
2) You may have more joy with "-mtime" rather than "-ctime" because many processes can interfere with "-ctime" (including backup software). To check what timestamp "-ctime" is looking at, list the directory with "ls -lac".
3) Test with "echo" not "rm" in the first instance.

Suggestion to help your diagnostics:

find /testfolder -maxdepth 2 -type f -mtime +1 -name "*.txt" -exec echo {} \;

hi
I took away -ls and it deletes the *.txt in /testfolder but not in the subfolder central.
rm appears fine /bin/rm.
Although ls -lac makes the file look old enough to delete with ctime, but i got it to work with mtime, thanks folks.
End command that works -

find /testfolder -maxdepth 2 -type f -mtime +1 -name "*.txt" -exec rm -rf {} \;
Elaine