Tuesday, 10 September 2013

how to exclude all subdirectories of a given directory in the search path of the find command in unix

how to exclude all subdirectories of a given directory in the search path
of the find command in unix

i need to backup all the directory hierarchy of our servers, thus i need
to list all the sub directories of some of the directories in the server.
the problem is that one of those sub directories contains tens of
thousands of sub directories (file with only the names of the sub
directories could take couple of hundreds megabytes and the respective
find command takes very long).
for example if i have a directory A and one sub directory A/a that
contains tens of thousands of sub directories. i want to use the find
command to list all the sub directories of A excluding all the sub
directories of A/a but not excluding A/a itself.
i tried many variations of -prune using the answers in this question to no
avail.
is there a way to use the find command in UNIX to do this?

No comments:

Post a Comment