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
recursive wc on a directory? bimba17 UNIX for Dummies Questions & Answers 13 06-21-2009 12:51 PM
Recursive search for group or other writeable 'dot' files maficdan Security 5 02-14-2008 09:43 PM
Restrict my search to current directory. sachin.gangadha UNIX for Dummies Questions & Answers 7 12-01-2007 12:37 PM
Recursive Search and replace only when found string umen Shell Programming and Scripting 1 05-07-2006 02:20 PM
Question about Restricting Search path of FIND to current directory super_duper_guy UNIX for Dummies Questions & Answers 2 10-17-2005 10:10 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 07-25-2008
puppala puppala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 5
Thumbs up non recursive search in the current directory only

Hi,

Am trying for a script which should delete more than 15 days older files in my current directory.Am using the below piece of code:

"find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/ls -altr {} \;"
"find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/rm -f {} \;"

But it is exploring sub directories too which i dont want have permission and dont want it to happen too.I just want to find and delete the files in the current directory alone.

Could any one of you please help me....
waiting for help!!

Thanks in advance...
  #2 (permalink)  
Old 07-25-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,313
You can add the "-prune" switch which will not have descent the search to subdirectories.
  #3 (permalink)  
Old 07-25-2008
puppala puppala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 5
Thanks for the reply..
could you please give me the complete syntax for my requirement...
  #4 (permalink)  
Old 07-28-2008
puppala puppala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 5
can anyone pls helpme out in this..non recursive search in the current directory only
problem descrobed above..

Thanks
  #5 (permalink)  
Old 07-28-2008
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Do a

Code:
man find

and you will get your answer. You can also check the maxdepth option.

Thanks..
  #6 (permalink)  
Old 07-28-2008
puppala puppala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 5
Sorry max depth option is not avilable for me...I have gone thru man pages..but i could not find any way can u pls be more explanatory...
  #7 (permalink)  
Old 07-28-2008
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Quote:
Originally Posted by puppala View Post
Sorry max depth option is not avilable for me...I have gone thru man pages..but i could not find any way can u pls be more explanatory...

Code:

find . -path '/directory/not/to/include' -prune -o -name "*" | xargs grep "pattern"

if you have many directories to exclude you can do something like this..

Code:
find . \( -path "/dir/to/exclude" -prune -o -path "/dir/to/exclude/" \) -name "*" | xargs grep "pattern"

Thanks
Namish

Last edited by namishtiwari; 07-28-2008 at 04:18 AM.. Reason: added for multiple dir
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 09:41 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