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 > 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
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 12:37 PM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
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
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM
how to find a file in UNIX without find command? bluo Shell Programming and Scripting 3 09-24-2003 11:47 PM

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 Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 05-04-2004
scmay scmay is offline
Registered User
  
 

Join Date: Apr 2004
Location: Melbourne
Posts: 15
Question find command

Hi,
I would need to find for files modified more than one day only in the current directory specified and NOT its subdirectories included.

How do I do this?
  #2 (permalink)  
Old 05-04-2004
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
  
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
you answered your own question.

use the find command.
search the forum for various example like what you are asking.
  #3 (permalink)  
Old 05-04-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
This is a complex command. And we have some threads with the wrong answer. So I'll do this again....

cd <directory>
find . \( ! -name . -prune \) -type f -mtime +1 -print
  #4 (permalink)  
Old 05-09-2004
scmay scmay is offline
Registered User
  
 

Join Date: Apr 2004
Location: Melbourne
Posts: 15
Re:

can you explain the \( ! -name . -prune \) ? Don't really understand that portion. Prune itself means not finding in its directory, but then ! -name . also means not to find in its own directory, right?

::
  #5 (permalink)  
Old 05-10-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Re: Re:

Quote:
Originally posted by scmay
can you explain the \( ! -name . -prune \)
It means if the name is not ".", do not look inside it. This is to stop "find" from descending into subdirectories.
  #6 (permalink)  
Old 05-10-2004
rameshonline rameshonline is offline
Registered User
  
 

Join Date: Apr 2004
Posts: 17
I think we can force find not to descend more than n levels. Isnt it ?

find . -name "*.c" -maxdepth 1

this will find all the ".c" files in the current directory only. It wont go beyond.
  #7 (permalink)  
Old 05-10-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
-maxdepth is non-standard...only gnu find has it as far as I know. Yes it will work if you have it.
Closed Thread

Bookmarks

Tags
linux, 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 04:12 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