The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can I know find syntax to find given date files bache_gowda Shell Programming and Scripting 3 03-26-2008 06:37 AM
How can I find files by date or size from stout? umen UNIX for Dummies Questions & Answers 2 01-13-2008 09:04 AM
find files by date kani Shell Programming and Scripting 1 10-25-2007 07:51 AM
Find all the files after the date? gkrishnag UNIX for Advanced & Expert Users 1 09-11-2006 12:15 PM
how to find files less than the current date mallikarjuna UNIX for Dummies Questions & Answers 4 01-20-2006 01:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2005
cbismuth cbismuth is offline
Registered User
  
 

Join Date: Jun 2005
Location: Paris, France
Posts: 1
BASH : Find files by date and shred them

Good afternoon everyone,

For security reasons, I need to delete files on a HDD I have to send after the ending of a demo.
I need to find all the files which not end by ".log" and which have been created for 45 days.
After getting the file list, I would like to use the shred command.

It would be like this :
Code:
$ find / -regex '^.*(!(\.log))$' -ctime 45 | xargs shred -fuvz
But this command line does not work.

Any help would be relevant,
Thanks a lot.

Christophe
  #2 (permalink)  
Old 06-13-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
There is no way in Unix to get a files creation time. You can find a files modification time, mtime, (you have ctime - the time when a files status was changed - check out the find man page), and if you can guarantee the file has not been modified since it was created, you have your creation time.

Anyway, the -regex looks to be an overcomplication.

find / ! -name "*.log" -mtime 45 | xargs shred -fuvz

If this doesn't work, chances are the files would have been modified after creation.

EDIT; if running this as root, and some important system files were modified 45 days ago, you are staring into the eyes of doom with a command like that.

Do a
find / ! -name "*.log" -mtime 45 -print
to see the output before adding the "destructive" pipe through to xargs shred.

Cheers
ZB

Last edited by zazzybob; 06-13-2005 at 11:34 AM..
  #3 (permalink)  
Old 06-13-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,126
Quote:
Originally Posted by cbismuth
I need to find all the files which not end by ".log" and which have been created for 45 days.
After getting the file list, I would like to use the shred command.
Quote:
Originally Posted by zazzybob
find / ! -name "*.log" -mtime 45 | xargs shred -fuvz

EDIT; if running this as root, and some important system files were modified 45 days ago, you are staring into the eyes of doom with a command like that.

Do a
find / ! -name "*.log" -mtime 45 -print
to see the output before adding the "destructive" pipe through to xargs shred.
I think it's actually worse than you think, ZB. Since the OP used the the past perfect tense, I would read that as:
... -mtime +44 ... # (I could not bring myself to type such a dangerous command in its entirety)

Destroy all files older than 45 days except for log files and a few newer files.

I can believe an attempt to destroy all files, but trying to leave stuff behind is weird. In any event shredding /dev/mem or /dev/kmem will panic the system for sure. But I doubt the command will get that far. We need some clarification here.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0