Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Unix cmd for find and remove
Name: Katie Date: August 10, 2001 at 05:52:57 Pacific
Comment:
I look for the Unix command that remove the files from the current directory which are more than 7 days old. Could you help me.
Name: Don Arnett Date: August 11, 2001 at 02:22:04 Pacific
Reply:
You can use the 'find' command for this. I don't remember the syntax for how to do this but have an example at work.
I'll look next time I go in. Probably tomorrow but possibly not until Monday.
0
Response Number 2
Name: Don Arnett Date: August 11, 2001 at 02:26:45 Pacific
Reply:
The answer to a post about 4 below this has the basics of what you want to do. See:
http://www.computing.net/unix/wwwboard/forum/2372.html (Need Help writing UNix script)
Note the -atime parameter, there are other parameters that can be used to check different types of time. For example, -ctime checks the create time I believe and mtime checks the last modified time, etc.
0
Response Number 3
Name: Siva Date: August 14, 2001 at 20:50:44 Pacific
Reply:
This will delete all the files accessed more than 7 days ago.
find -depth -atime +7 -exec rm {} ;
Before you run the above replace rm with ls -l and run to see what files will be deleted.
good luck
0
Response Number 4
Name: James Boothe Date: August 27, 2001 at 15:43:22 Pacific
Reply:
The first parameter needs to be pathname (which is a dot in following example to specify the current directory). And the semicolon will need to be escaped by preceeding it with a backslash: find . -depth -atime +7 -exec rm {} \;
Summary: Hi Can you please tell me the command for finding out on a unix box List of all filenames, file sizes and cksum values for all files and sub folders I am using right now the below find . -exec cksum ...
Summary: Hi, I'm trying to use a combination of find -exec and grep with little success. Basically, I need a script to search for files modified within the last day that match a certain filenaming pattern. I...
Summary: Does anyone know where I could find a Unix driver for a HPLaserJet 100xi. I've tried a lot of different websites, and have even called HP for help. No Dice. ...