![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting specfic files older than N days | eurouno | UNIX for Dummies Questions & Answers | 3 | 07-18-2008 10:48 PM |
| Deleting files older than 7 days | shezam | Shell Programming and Scripting | 4 | 07-09-2008 04:40 AM |
| Deleting / finding files older than X days missess a day | guruparan18 | Shell Programming and Scripting | 4 | 05-08-2008 06:09 AM |
| Deleting Files Older than 24 hours | mazhar803 | SUN Solaris | 7 | 09-27-2007 07:30 AM |
| Deleting files older than a given date | rajugp1 | Shell Programming and Scripting | 3 | 12-09-2002 02:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Deleting older files of a particular type
hi
This should be easy but i'm obviously missing something obvious. ![]() 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 |
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
Quote:
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: Code:
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|