If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Stop unix find command from reading or trying to read: sub-directories

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-18-07, 00:32
spacebar spacebar is offline
Registered User
 
Join Date: Feb 2006
Posts: 73
Question Stop unix find command from reading or trying to read: sub-directories

How do you tell the find command to NOT read sub-directories ( or from trying to ) when searching for a file?

/tmp directory list:
-rw-rw-r-- 1 brown dev 0 Jan 31 08:46 bar_1.txt
drwx------ 2 root root 182 Feb 23 16:50 smc898
drwx------ 2 webadmin webadmin 422 Feb 23 16:51 https-fpdbtst1.fuelman.com-ab0d7966
drwxr----- 2 oracle dba 179 May 17 12:26 hsperfdata_oracle


It is correctly finding the file and the messages about trying to access the sub-directories are not a big deal because I've got them going to a log file but I know there has got to be a way to tell "find" not to process sub-directories.

These are the 3 different command formats I've tried:

/tmp/ > find /tmp -name "bar_*.txt" -type f -prune -mtime +1
find: cannot read dir /tmp/smc898: Permission denied
find: cannot read dir /tmp/https-fpdbtst1.fuelman.com-ab0d7966: Permission denied
find: cannot read dir /tmp/hsperfdata_oracle: Permission denied
/tmp/bar_1.txt

/tmp/ > find /tmp -name "bar_*.txt" -mtime +1 -type f -prune
find: cannot read dir /tmp/smc898: Permission denied
find: cannot read dir /tmp/https-fpdbtst1.fuelman.com-ab0d7966: Permission denied
find: cannot read dir /tmp/hsperfdata_oracle: Permission denied
/tmp/bar_1.txt

/tmp/ > find /tmp -name bar_*.txt -mtime +1 -type f -prune
find: cannot read dir /tmp/smc898: Permission denied
find: cannot read dir /tmp/https-fpdbtst1.fuelman.com-ab0d7966: Permission denied
find: cannot read dir /tmp/hsperfdata_oracle: Permission denied
/tmp/bar_1.txt

tia
Reply With Quote
  #2 (permalink)  
Old 05-18-07, 06:05
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Try
Code:
find /tmp -depth -name "bar_*.txt" -mtime +1 -type f -prune
Regards
Reply With Quote
  #3 (permalink)  
Old 05-18-07, 18:07
spacebar spacebar is offline
Registered User
 
Join Date: Feb 2006
Posts: 73
fpdbtst1:/tmp/ > find /tmp -depth -name "bar_*.txt" -mtime +1 -type f -prune
find: cannot read dir /tmp/smc898: Permission denied
find: cannot read dir /tmp/https-fpdbtst1.fuelman.com-ab0d7966: Permission denied
find: cannot read dir /tmp/hsperfdata_oracle: Permission denied
/tmp/bar_1.txt


...Same results
Reply With Quote
  #4 (permalink)  
Old 05-20-07, 07:06
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Hi,

Don't exactly know why but I think this:
Code:
find /tmp ! -name . -prune -name "bar_*.txt" -mtime +1 -type f
will work. Adopted from the stuff written here http://www.in-ulm.de/~mascheck/various/find/

Regards
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On