find a dir under a dir

find a dir under a dir

Post by Gary Weimer (645 » Sat, 02 Dec 1995 04:00:00




|> Hello Gentlemen,
|>
|> Small problem:
|>
|> My solution for finding the cache directory below .netscape was (I
|> couldn't do find ...  -name .netscape/cache, so I'm sorry for the
|> length):
|>
|> find /users -fstype hfs -name .netscape -exec sh -c "find \$1 -name
|> cache -exec du -s {} \;" {} \;

If cache is always directly under .netscape, you don't need the second
find:

find /users -fstype hfs -name .netscape -exec du -s {}/cache \;

--
Gary Weimer

profs: WEIMER(EKSMTP)                     pager: 716 975 0420

 
 
 

find a dir under a dir

Post by Roman Fiet » Sat, 02 Dec 1995 04:00:00



   I want to find a directory d2 below a directory d1. All directories
   with the name d1 below other directories shlould be ignored. On these
   directories execute a command.

   My solution for finding the cache directory below .netscape was (I
   couldn't do find ...  -name .netscape/cache, so I'm sorry for the
   length):

   find /users -fstype hfs -name .netscape -exec sh -c "find \$1 -name
   cache -exec du -s {} \;" {} \;

   Any better idea?

Sorry for the quick shot.

find /users -type d -print | egrep "/\.netscape/cache$|/\.netscape-cache$" | xargs du -s

Roman
--
Roman Fietze (Mail Code 5023)              Kodak AG Stuttgart/Germany


 
 
 

find a dir under a dir

Post by Gary Weimer (645 » Sat, 02 Dec 1995 04:00:00



|>
|> My solution for finding the cache directory below .netscape was (I
|> couldn't do find ...  -name .netscape/cache, so I'm sorry for the
|> length):
|>
|> find /users -fstype hfs -name .netscape -exec sh -c "find \$1 -name
|> cache -exec du -s {} \;" {} \;

Sorry,  find /users -fstype hfs -name .netscape -exec du -s {}/cache \;
doesn't work (at least under Solaris). Since the {} are adjacent to
other text, it is not replaced with the found file... (I did a quick
check using {}/bin and didn't realize until after I posted that it just
used /bin.)

If your solution above works (under Solaris 2.4, $1 is always NULL), the
following should work (ignores cache if size is zero):

find /users -fstype hfs -name .netscape -exec sh -c "test -s \$1/cache
&& du -s \$1/cache" {} \;

If you want to assume cache always exists, you can shorten this to:

find /users -fstype hfs -name .netscape -exec sh -c "du -s \$1/cache" {} \;

--
Gary Weimer

profs: WEIMER(EKSMTP)                     pager: 716 975 0420

 
 
 

find a dir under a dir

Post by Roman Fiet » Sat, 02 Dec 1995 04:00:00


Hello Gentlemen,

Small problem:

I want to find a directory d2 below a directory d1. All directories
with the name d1 below other directories shlould be ignored. On these
directories execute a command.

My solution for finding the cache directory below .netscape was (I
couldn't do find ...  -name .netscape/cache, so I'm sorry for the
length):

find /users -fstype hfs -name .netscape -exec sh -c "find \$1 -name
cache -exec du -s {} \;" {} \;

Any better idea?

Roman
--
Roman Fietze (Mail Code 5023)              Kodak AG Stuttgart/Germany

 
 
 

find a dir under a dir

Post by Bill Marc » Mon, 04 Dec 1995 04:00:00




>Hello Gentlemen,

>Small problem:

>I want to find a directory d2 below a directory d1. All directories
>with the name d1 below other directories shlould be ignored. On these
>directories execute a command.

>My solution for finding the cache directory below .netscape was (I
>couldn't do find ...  -name .netscape/cache, so I'm sorry for the
>length):

>find /users -fstype hfs -name .netscape -exec sh -c "find \$1 -name
>cache -exec du -s {} \;" {} \;

I'm not familiar with Netscape, so I don't know if there could be
multiple cache directories under a single .netscape dir.  But if each
.netscape has only one .netscape/cache directory, the second "find" is
not needed.  You could simply do:
find /users -fstype hfs -name .netscape -exec du -s {}/cache \;

--
"Goodness me, could this be industrial disease?"  Dire Straits