The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 06:47 AM
UNIX Find command in Borne Shell marshaferry Shell Programming and Scripting 1 04-06-2006 11:47 AM
how to find a file in UNIX without find command? bluo Shell Programming and Scripting 3 09-24-2003 11:47 PM
How to find the exit status of last command in Unix? rajugp1 High Level Programming 1 09-10-2002 11:52 AM
how to find a command in Unix? lacasa UNIX for Dummies Questions & Answers 1 02-22-2001 03:49 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-09-2007
scriptingmani scriptingmani is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 17
The UNIX find command

Hi All,

I trying to get my head around using the find command and i wanted to list a selection of files that are older than 30 days. i used 'find . -mtime +30' and it lists all the files including other files from the current location's sub directory. i then used the prune option but it seems it doesn't work 'find . -mtime +30 -prune'. The location i am trying to find files is in my local directory

/local/home/***/print/

the directory print has sub directory called 'backup'.

any help kindly appreciated.

Mani
  #2 (permalink)  
Old 07-09-2007
jgt jgt is offline
Registered User
  
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 439
Add the "-level 0" option to the command
  #3 (permalink)  
Old 07-09-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try:
find . -prune -mtime +30
  #4 (permalink)  
Old 07-10-2007
dmwaff dmwaff is offline
Registered User
  
 

Join Date: Aug 2001
Location: Texas
Posts: 17
I may have read the posting incorrectly, but if you are attempting to exclude the the backup and/or print subdirectory and operate only on the the rest of the home, then:

find /local/home/username -name print -prune -o -mtime +30 -ls

mutliple prunes if you want (spaces important)

find /local/home/username \( -name print -o -name dir2 -o -name dir3 \) -prune -o -mtime +30 -print

-David
  #5 (permalink)  
Old 07-10-2007
scriptingmani scriptingmani is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 17
hi, thanks for all your replies.

dmwaff, apologies for any misunderstanding, what i wanted was to find the contents 30+ days old only in the print directory and not its subdirectory "backup"

i tried :

find /local/home/*username*/print/ -name print -prune -o -mtime +30

and it returns everything 30+ days old in 'print' and in the sub directory 'backup'.

i tried:

find . -prune -mtime +30

and it doesn't return anything even with a -ls option at the end.


i went back one directory into my username directory and tried the following commands

find . -name 'print' -mtime +30
find ./ -name print -mtime +30

but nothing, no display or error message of incorrect usage even with an -ls or -prune option. I did a check on the contents of the directory and there are files dating back from 2006, from May and June 2007, which it should pick up and display
  #6 (permalink)  
Old 07-10-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
To find files (not directories) in the current directory old than 30 days without descending into subdirectories, use:
find . ! -name . -prune -type f -mtime +30

If you want to find old directories too without descending into them:
find . ! -name . -prune -mtime +30
Sponsored Links
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 11:45 PM.


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