Running find in all directories except one


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running find in all directories except one
# 1  
Old 10-19-2010
Running find in all directories except one

hi,

in a directory called dir1 with subdir :

dir11
dir12
dir13
dir14

i'm using this kind of request in ksh:

find /dir1 -name '*txt' |wc -l

i want now to run the same request but without going down in the subdir dir14

is there a simple way to do that ?
if not what do you suggest :
keeping the wanted subdirs in a special file and looping the find in it on each subdir ?

i 'll appreciate your help

regards
Christian
# 2  
Old 10-19-2010
Three successive thoughs:
Code:
find $( ls /*/ | grep -v '/dir14/' ) . . .

ls /*/ | grep -v '/dir14/' | while read d
do
 find $d . . .
done

for d in /*/
do
 if [ "$d" != "/dir14/" ]
 then
  find $d . . .
 fi
done

# 3  
Old 10-19-2010
Code:
find . -name "*.txt" ! -path '*dir14*' -prune


Last edited by cabrao; 10-19-2010 at 12:04 PM..
# 4  
Old 10-19-2010
FIND

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



---------- Post updated at 11:06 AM ---------- Previous update was at 11:05 AM ----------

If you like delving into complex options in the find man page! Smilie
# 5  
Old 10-20-2010
thanks for ypur thoughts , i will try them.

regards
Christian

---------- Post updated at 03:58 PM ---------- Previous update was at 09:23 AM ----------

hi,

i tried your thoughts with success and i choosed this one :

ls /*/ | grep -v '/dir14/' | while read d
do
find $d . . .
done


is it possible to use this statement in a rsh command ?

i tried :

rsh myhost -l username "ls /dir1 | grep -v 'dir14' | while read d
do
find /dir1/$d -name '*.txt' -size +4000000 -exec ls -g {} \;
done
"

it seems that th variable $d in the find statement is not filled !

any idea ?

regards
Christian
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running program and output files in specific directories

I have been running a program mseed2sac using the following command cd IV find . -type f -exec /swadmin/mseed2sac '{}' \; The problem is that I end up with a lot of files in directory IV. Instead I would like to select the designator HHZ, create a directory IV.SAC and all the files output... (11 Replies)
Discussion started by: kristinu
11 Replies

2. 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

3. Shell Programming and Scripting

Automate the process of running jobs on several directories consecutively

Hi, I have about 10 directories in which I run the same code. But this code is only run in a directory when the computation in the previous directory was successful (explained below). My directories are named as : VF_50, VF_100, VF_150, VF_200............. As you can see the number after _... (6 Replies)
Discussion started by: lost.identity
6 Replies

4. Shell Programming and Scripting

Find directories with same name and rename them

Hello Im trying to make a script in bash shell programming to find subdirectories with the same name into the same directory and rename one of them!! Could you please help me? Thanks in advance (1 Reply)
Discussion started by: BTKBaaMMM
1 Replies

5. Shell Programming and Scripting

How to find 777 permisson is there or not for Directories and sub-directories

Hi All, I am Oracle Apps Tech guy, I have a requirement to find 777 permission is there or not for all Folders and Sub-folders Under APPL_TOP (Folder/directory) with below conditions i) the directory names should start with xx..... (like xxau,xxcfi,xxcca...etc) and exclude the directory... (11 Replies)
Discussion started by: gagan4599
11 Replies

6. Shell Programming and Scripting

Find Directories That Do Not Contain A Certain File

I'm having problems figuring out the process to find directories that DO NOT contain a certain file. I have a mp3 collection that all the album art is name "folder.jpg". Not all the albums have images. I need a way to find the albums/directories that do not contain "folder.jpg". I can find the... (2 Replies)
Discussion started by: subsonic
2 Replies

7. Shell Programming and Scripting

find directories

I am looking a script which will find garbase directories (10 char. long)..which need to delete empty dir excluding symlink and system directories. I tried this partial script but it just find directories create a file which contains link directories..can somebody help me to complete this... (4 Replies)
Discussion started by: ddk2oo5
4 Replies

8. Shell Programming and Scripting

running a script in different directories

hi, I have a peculiar problem I am working in bash shell There is one particular directory in my unix box For the scripts present in that directory, if i put sh <script name> it is working fine if i put ksh <script name> the corresponding script is not even executing but apart from that... (3 Replies)
Discussion started by: trichyselva
3 Replies

9. Shell Programming and Scripting

Find but exclude directories

Hello, I have a line in my script to find the files changed in the last 24 hours. It is as below: find /home/hary -type f -mtime -1 I now want to exclude a directory named "/home/hary/temp/cache" from the above find command. How do I add it to my script? Any help is appreciated. ... (9 Replies)
Discussion started by: tadi18
9 Replies

10. Shell Programming and Scripting

Find files in Directories

Hello, We have in a file a list of the path of files from one server. We want to search if these files exist on another server , but the path on this new server isn't the same. We want to use the command "awk" but there isn't the god way. Example: on server 1 in a file : listServer1.txt... (4 Replies)
Discussion started by: steiner
4 Replies
Login or Register to Ask a Question