![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is there an efficient way in finding and deleting files? | guruparan18 | Shell Programming and Scripting | 3 | 05-26-2008 10:07 PM |
| Deleting / finding files older than X days missess a day | guruparan18 | Shell Programming and Scripting | 4 | 05-08-2008 03:09 AM |
| Deleting Files | bc4 | UNIX for Dummies Questions & Answers | 1 | 01-25-2007 08:27 PM |
| finding duplicate files by size and finding pattern matching and its count | jerome Sukumar | Shell Programming and Scripting | 2 | 12-01-2006 01:20 AM |
| Deleting old files | shiroh_1982 | Shell Programming and Scripting | 2 | 06-21-2006 01:42 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Help with finding certain files, and then deleting
I must really be bad at life today, because I couldn't even find a search option on the forums before asking for help, so I apologize if this is already listed somewhere.
I'm pretty new to UNIX, and basically only know enough to be dangerous. I have been appointed a task to basically go to a directory, find all files that begin with a certain phrase (smith, jones, etc.) and then delete all files that are older than 90 days. Any files within the last 90 days need to be compressed into a TAR file and then archived and moved to another folder. The problem i'm having is twofold. One, I can't figure out how to get a good listing of all files older than 90 days using the search criteria of the filename (all files starting with jones over the last 90 days). I don't even know if I need this, but I thought it was a good start. I need to delete all these files > 90 days with the certain filename delimiters regardless. I've tried find, but can't figure out the switches, and I can find all the files with the name i'm looking for using ls -lrt | grep jones but that isn't doing me much good. I've searched Google for examples but haven't had any luck yet and am trying hard not to get fired, so I figured posting might be a faster solution. Once I get those deleted, I need to then archive the files within the last 90 days into a tar and then move that file (or files?) into another directory. If anyone can help, i'd appreciate it. Much thanks. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Wow, I now see search functions for the forum. I guess they weren't showing up when I was registered but not activated. I suck at the internets today, I swear.
|
|
#3
|
|||
|
|||
|
you really need to look at find man page
you should be able to find file with Code:
find /path -name "smith*" Code:
find /path -name "smith*" -exec rm -r {} \;
Code:
find /path -name "smith*" -mtime +90 -exec rm -r {} \;
You should also read about regexp (man regexp) so you can find the right expression to put in -name "expression" |
|||
| Google The UNIX and Linux Forums |