SUMMARY: Find to exclude dirs/subdirs

From: Bhavesh Shah <bshah_at_citadon.com>
Date: Tue Apr 13 2004 - 15:24:38 EDT
I got two replies and very thankful to them for their valuable
suggestions:

Russell

It might be easier to create the list of directories with find, and then


process it with sed to remove the ones you don't want. If the list isn't


all that big, and you don't need to do this very often, it may be

worthwhile fixing it in an editor.

Oscar

would use the find command to list the directories and
then pipe the output into grep or xargs and filter the directories
there.
You would issue a mkdir command only on the ones that
satisfied the criteria



But I figured out the solution:

To Exclude DIR1, DIR2 and DIR3 from list simply use:

find / -type d \( -name DIR1 -o -name DIR2 -o -name DIR3 \) -prune -o
-type d -print



My Original Question was:

Hi Gurus,

I have a shell script which creates a Dir structure to newly created Sun
Box from a File which has Dir List.

I would like to create a New File with a complete Dir structure
excluding certain Directories (Only Dirs not files)



If I use

find . -type d



will give me a recursive list of Dirs in a current Dir which is fine.



find . -type d ! -name '[0-9]*'

will exclude Dirs which starts with numbers but to exclude mutilple dirs




find . -type d ! -name '[0-9]*' -o -type d ! -name . -o -type d -name NT

doesn't work neither

find . -type d ! \( -name '[0-9]*' -o -name NT -o -name .snapshot \)
-print



I tried -prune switch as well but it lists files as well besides
directories.

 Also tried ls -d * / but it gives dir list in current Dir only not the
recursively



My question is:

How can I exclude multiple directories with find command?  I am running
Solaris 8

Do I need any other tool ? or which is a best way to create a dir list
recursively in a current dir without files listing?



Any Help will be greatly Appreciated.

Thanks in advance

B
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Apr 13 15:24:31 2004

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:31 EST