The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-13-2007
Registered User
 

Join Date: Mar 2007
Posts: 3
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.
Reply With Quote
Forum Sponsor
  #2  
Old 03-13-2007
Registered User
 

Join Date: Mar 2007
Posts: 3
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.
Reply With Quote
  #3  
Old 03-13-2007
Registered User
 

Join Date: Feb 2007
Posts: 10
you really need to look at find man page

you should be able to find file with

Code:
find /path -name "smith*"
you are able to execute any command with -exec flag to find :

Code:
find /path -name "smith*" -exec rm -r {} \;
To find files older than 90 days you can have a look at -mtime, -ctime and -atime

Code:
find /path -name "smith*" -mtime +90 -exec rm -r {} \;
Sorry, I don't have more time for this right now .... if you need precision after looking at find man page, post back here.

You should also read about regexp (man regexp) so you can find the right expression to put in -name "expression"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0