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
Purge files based on timestamp avl in file name sureshg_sampat Shell Programming and Scripting 3 02-29-2008 11:28 AM
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 07:47 AM
Read from file then purge or archive. kayarsenal Shell Programming and Scripting 15 08-10-2006 09:24 AM
Purge files, keep 3 versions of last 4 days blt123 Shell Programming and Scripting 7 10-28-2002 09:49 PM
purge xterm noobie_doo UNIX for Dummies Questions & Answers 1 03-27-2002 03:53 AM

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 10-19-2007
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
Find and purge a files in a dir

HI All,

I have recuirement to purge the files in a directory . In that directory i an having many sub-directory .

When i use find command like
find ~/work/test/insert -name "*.*" -mtime +12

it is listing the file not accesed before 12 , It also takes the subdirectories inside the directory ~/work/test/insert .

I want to conside only this directory , not the subdirectories in find . PLease let me know how i can be done.



offcourse i searched the form but this is not working for me

find ~/work/test/insert \(! -name ."*.*") -type f -mtime +1 -print

Thanks,
Arun.
  #2 (permalink)  
Old 10-19-2007
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
i know this command is wrong


find ~/work/test/insert \(! -name ."*.*") -type f -mtime +1 -print

i have also done as

find ~/work/test/insert \(! -name ."*.*"\) -type f -mtime +1 -print

the same is also not working .... is there is a way to do this to find only in a directory omitting its sub directory???
  #3 (permalink)  
Old 10-19-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
The solution depends on the version of find you're using:

Code:
find .  -name . -prune -type f -mtime +12
Code:
find . -maxdepth 1 -type f -mtime +12
  #4 (permalink)  
Old 10-19-2007
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
find . ! -name . -prune -mtime +1

This commands work for me .. But i need to specify hthe directory .. If i do like this

find /working/can/transfer ! -name . -prune -mtime +1

or
find /working/can/transfer ! -name . -prune "*.*" -mtime +1

is not working . please let mew know what needs to change ..

Thanks,
Arun
  #5 (permalink)  
Old 10-19-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
Code:
find /working/can/transfer/. ! -name . -prune -type f -mtime +1
Don't get confused by the path (/./), it's valid
  #6 (permalink)  
Old 10-19-2007
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
That was really great !... Thanks...

Just a question my command is

find /working/can/transfer/ -name "*.*" -mtime +1 -exec rm -f -r

is there is any way to work with this command like include -prune i tried with

find /working/can/transfer/ -name -prune "*.*" -mtime +1 -exec rm -f -r

it is not working can i know why it is ???..

Thanks,
Arun
Closed Thread

Bookmarks

Tags
mtime

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