[Summary] let find to skip lost+found directory

From: Michael Wang (mwang@tech.cicg.ml.com)
Date: Fri Jul 02 1999 - 10:03:47 CDT


I got many replies but none of suggestions work. The summary is
attached below. Thanks for anyone who replied.

Michael Wang
http://www.mindspring.com/~mwang

== setup ==
#510>pwd
/export/apps/oracle
 
#511>ls -ls
total 350
   2 drwxr-xr-x 2 root root 512 Nov 2 1998 TT_DB
   2 drwxr-xr-x 6 oracle dba 512 Nov 3 1998 admin
   2 -rw-r--r-- 1 oracle dba 35 Sep 15 1998 afiedt.buf
   4 -rw------- 1 oracle dba 1338 Sep 1 1998 dead.letter
   2 drwxr-xr-x 6 oracle dba 512 Aug 18 1998 local
  16 drwx------ 2 root root 8192 Aug 17 1998 lost+found
   2 drwxr-xr-x 4 oracle dba 512 Oct 30 1998 product
 320 -rw-r--r-- 1 oracle dba 148216 Sep 15 1998 sqlnet.log

== objective ==

   to let find skip lost+found directory.
   use echo $? to indicate if find traverses all directories.

== suggestions that do not work ==

#507>find . ! -name "lost+found" -prune -print
.
 
#508>find * ! -name "lost+found" -prune -print > /dev/null
find: cannot read dir lost+found: Permission denied
#509>echo $?
1

#512>find . -name core -print > /dev/null
find: cannot read dir ./lost+found: Permission denied
#513>echo $?
1

#514>find /export/apps/oracle -name core -print
find: cannot read dir /export/apps/oracle/lost+found: Permission denied

#521>find . -name lost+found -prune -o -print > /dev/null
find: cannot read dir ./lost+found: Permission denied
#522>echo $?
1

#523>find . -print -name lost+found -prune > /dev/null
find: cannot read dir ./lost+found: Permission denied

find ... 2> /dev/null
# problem: exit status is still 1
# throw away all other error messages.

#524>/bin/find * -prune -print dead.letter local
/bin/find: bad option dead.letter
/bin/find: path-list predicate-list

        for each file
           skip if file == lost+found
           do the find on just that one file/directory
        end
# Hmmm a loop for this seemingly simple problem

 you could change the ownership of lost+found to oracle
 (or whatever username that does the find command) but
 that'd a kludge ... and might create other problems later on

#525>find /export/apps/oracle -name core -mount -print > /dev/null
find: cannot read dir /export/apps/oracle/lost+found: Permission denied

#526>find /export/apps/oracle -name 'lost+found' -prune -o -name 'core' -print
find: cannot read dir /export/apps/oracle/lost+found: Permission denied

Rather than test on exit code, why not something like....
  files=`find / -name core -print 2>&1 | grep -v "lost+found"`
  if [ ! -z "$files" ]
  then
    echo The following core files were found:
    echo "$files"
  fi

#527>find . -name core -type f -prune -print > /dev/null
find: cannot read dir ./lost+found: Permission denied

find . -print | grep -v lost+found
# this only hide the problem



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:13:23 CDT