Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Running find in all directories except one


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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  
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  
Code:
find . -name "*.txt" ! -path '*dir14*' -prune


Last edited by cabrao; 10-19-2010 at 12:04 PM..
# 4  
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  
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 Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Running program and output files in specific directories
kristinu
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...... Shell Programming and Scripting
11
Shell Programming and Scripting
Using grep command to find the pattern of text in all directories and sub-directories.
vinothrajan55
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?... UNIX for Dummies Questions & Answers
1
UNIX for Dummies Questions & Answers
Automate the process of running jobs on several directories consecutively
lost.identity
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 _...... Shell Programming and Scripting
6
Shell Programming and Scripting
How to find 777 permisson is there or not for Directories and sub-directories
gagan4599
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...... Shell Programming and Scripting
11
Shell Programming and Scripting
running a script in different directories
trichyselva
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...... Shell Programming and Scripting
3
Shell Programming and Scripting

Featured Tech Videos