Re: 'find' command

charlie thibault (cth@bruker.com)
Wed, 12 Jan 94 10:13:23 EST

According to Martin J. Dellwo:
>
> I am trying to find files owned or not owned by specific users (such as root)
> on our AMX 500 computer. The standard unix program 'find' does not
> work as expected. A command of the form
>
> find . -user root -exec ls -l {} \;
>
> gives strange output. *Every* file in the directory is listed,
> followed by the ones I want:
> [...undesired output deleted...]
> Can anyone help explain? Thanks.

The problem is not with the find command but with way you are trying
to list the files found. The find command as written will find both
files and directories. If the {} evaluates to a directory then the
"ls -l" command will list the _contents_ of the directory (regardless of
the ownership of the individual files). If you only want the _name_ of
the directory or file printed then use "ls -ld". Another option is to
replace the "-exec ... " with "-print". If you are only interested in
files and not directories use the "-type f" option. Try one of the
following commands to get the desired result:

find . -user root -exec ls -ld {} \;
find . -user root -print
find . \( -user root -a -type f \) -exec ls -ld {} \;

(BTW all these commands behave the same on X32s, Suns, and SGIs.)

-- 
==================================================================
	
       ...     ...	Charles G. Thibault
      .    * .    .	Manager of Software Development
       .   . .   .	Bruker Instruments Inc.
       B R U K E R	Billerica, MA. 01821 USA
       .   . .   .	(508)667-9580 x218
      .    * .    .	cth@bii.bruker.com		Internet
       ...     ...     ...!uunet!bii!cth		UUCP

=================================================================