find command takes a lot of time ( can I skip directories)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find command takes a lot of time ( can I skip directories)
# 1  
Old 03-18-2008
find command takes a lot of time ( can I skip directories)

I have a file called "library" with the following content

libnxrdbmgr.a
libnxrdbmgr.so
libnxtk.a
libnxtk.so
libora0d_nsc_osi.so

I am trying to locate if these libraries are on my machine or not. find command runs for about few seconds and hangs after this.
Can someone please help me and let me know if there is a better way. Is there a way I can ignore a directory and its sub directories during the find process

find: cannot read dir /ssttools/performance/RMCmem: Permission denied


$ for i in `cat library`
do
find / -name $i -print | grep $i >> outputfile
done




find: cannot read dir /proc/24250: Permission denied
find: cannot read dir /proc/17502: Permission denied
find: cannot read dir /tmp/smc898: Permission denied
find: cannot read dir /tmp/config_pvr: Permission denied
find: cannot read dir /export/home/dwgore/.rhosts: Permission denied
find: cannot read dir /export/home/mgalvin/.rhosts: Permission denied
find: cannot read dir /export/home/nmsbb/.ssh: Permission denied
find: cannot read dir /export/home/www/.ssh: Permission denied
find: cannot read dir /ssttools/performance/RMCmem: Permission denied

It is taking a lot of time here before it can go to next
# 2  
Old 03-18-2008
There are few directories which I want the find command to skip or ignore and move on. How do I modify the find command so that it skips these directories

find: cannot read dir /export/home/www/.ssh: Permission denied

find: cannot read dir /ssttools/performance/RMCmem: Permission denied
find: cannot read dir /ssttools/tng/focus: Permission denied
# 3  
Old 03-19-2008
from the man pages:
Code:
       -path pattern
              File name matches shell pattern pattern.  The metacharacters do not treat ‘/'  or  ‘.'  specially;  so,  for
              example,
                        find . -path './sr*sc'
              will  print an entry for a directory called './src/misc' (if one exists).  To ignore a whole directory tree,
              use -prune rather than checking every file in the tree.  For example, to skip the directory ‘src/emacs'  and
              all files and directories under it, and print the names of the other files found, do something like this:
                        find . -path './src/emacs' -prune -o -print

# 4  
Old 08-12-2008
How about a situation where you only want to find all regular files, but omit certain directories? Eg, i tried:

find . -name 'dir1' -prune -o name 'dir2' -prune -o type f

And the above does give me just regular files, except i get an entry for 'dir1' and 'dir2'; even though none of the files underneath these directories appear in the final list (which is what i want). I also want to omit the 'dir1' and the 'dir2' entries. They're the only things that show up in my output that are not regular files.

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude directories in FIND command

Can you please help tweak the below command to exclude all directories with the name "logs" and "tmp" find . -type f \( ! -name "*.tar*" ! -name "*.bkp*" \) -exec /usr/xpg4/bin/grep -i "user_1" /dev/null {} + >result.out bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. Shell Programming and Scripting

Find command takes long

Hi, I am trying to search for a Directory called "mont" under a directory path "/opt/app/var/dumps" Although "mont" is in the very parent directory called "dumps" i.e "/opt/app/var/dumps/mont" and it can never be inside any Sub-Directory of "dumps"; my below find command which also checks... (5 Replies)
Discussion started by: mohtashims
5 Replies

3. UNIX for Advanced & Expert Users

Find command takes too long to complete

Hi, Below is my find command find /opt/app/websphere -name myfolder -perm -600 | wc -l At time it even takes 20 mins to complete. my OS is : SunOS mypc 5.10 Generic_150400-09 sun4v sparc SUNW,T5440 (10 Replies)
Discussion started by: mohtashims
10 Replies

4. AIX

AIX_timeout_thread using lot of cpu time

Hi, i am seeing some strange things on a lpar which we have at this moment. With nmon i see a process aix_timeout_thread which is using lots of cpu (70-80%, all cpu which is "free" is used). This is a kernel process (for as far i can find out) but i am wondering what is causing this to happen... (5 Replies)
Discussion started by: aixvinnie
5 Replies

5. Shell Programming and Scripting

sed command to skip the first line during find and replace operation

Hi Gurus, I did an exhaustive search for finding the script using "sed" to exclude the first line of file during find and replace. The first line in my file is the header names. Thanks for your help.. (4 Replies)
Discussion started by: ks_reddy
4 Replies

6. UNIX for Dummies Questions & Answers

Using grep command to find the pattern of text in all directories and sub-directories.

Hi all, Using grep command, i want to find the pattern of text in all directories and sub-directories. e.g: if i want to search for a pattern named "parmeter", i used the command grep -i "param" ../* is this correct? (1 Reply)
Discussion started by: vinothrajan55
1 Replies

7. UNIX for Advanced & Expert Users

command taking lot of time to execute

Hi, I am running the following command, and it tries to delete some dn from ldap, however, it takes lot of time before it finally request LDAP server to delete it. I am trying to find why it is taking lot of time. Could you anyone help me in this regard. I have copies the pstack output, and... (3 Replies)
Discussion started by: john_prince
3 Replies

8. Shell Programming and Scripting

Help - Find command to exclude sub-directories

Hi Forum. I'm trying to write a script that finds and deletes files that are older than 300 days. The script will read a table that contains the following 3 columns: 1st col: “Y” means sub-directory scan; "N" means no subdirectory scan 2nd col: sub-directory location 3rd col: File prefix... (7 Replies)
Discussion started by: pchang
7 Replies

9. Solaris

Telnet/ssh connection takes a lot of time.

We have three Oracle instances running on our Sun-Blade-T6300. Telnet or SSH connection to one of the instance (or to user oramach) takes a lot of time whether using putty or SecureCRT but connection to any other user is very fast. Any idea what may be causing this slow connection to this... (5 Replies)
Discussion started by: esmgr
5 Replies

10. UNIX for Dummies Questions & Answers

find command to exclude directories

Howdy I have this directory structure ... eep eepaptest eepfatest eepgltest eep.old eeppoptest ehf ehfaptest ehfgltest ehp ehpgltest I want to find files in these directories, but I want to exclude eep, ehf & ehp. Cany anyone help with the correct command ?? (1 Reply)
Discussion started by: SmurfGGM
1 Replies
Login or Register to Ask a Question