[comp.unix.questions] Do you use find command?

maryhc@hpcc01.HP.COM (Mary Hsia-Coron) (05/17/91)

Do you use the -print and -depth options with the find command?

-print option:
--------------
All the manual pages I've read recommend using -print to display
output from find. I've found that -print is unnecessary
on my HP-UX systems (7.0 HP-UX and later releases). For example, 
              find / -user pat
works fine.

Question:
---------
On your UNIX system, must -print be used to display the results of
find? (Please state what flavor of UNIX you have: ULTRIX, SUN, ZENIX, etc.)

-depth option:
--------------
The AT&T System V manual pages say that when find is used with cpio,
-depth should be used to list files in directories without write
permission. For example:
       find / -name report -depth | cpio -ov > /dev/rmt/0h

On HP-UX systems, find will list files in directories without write
permission even when -depth is NOT used.

Question:
---------
On your UNIX system, must find be used with -depth when piping to cpio?
(Please state what flavor of UNIX you have: ULTRIX, SUN, ZENIX, etc.)


I'm documenting use of find on UNIX systems IN GENERAL and want to make the
right recommendations about whether to use -print and -depth. I was going
to recommend that both options not be used.
 

Thanks for any info you can provide!
Mary Hsia-Coron
Hewlett-Packard Customer Training
mary@hpasdd.hp.com

urban@cbnewsl.att.com (john.urban) (05/17/91)

In article <2570005@hpcc01.HP.COM> maryhc@hpcc01.HP.COM (Mary Hsia-Coron) writes:
>
>Do you use the -print and -depth options with the find command?
>
>-print option:
>--------------
>All the manual pages I've read recommend using -print to display
>output from find. I've found that -print is unnecessary
>on my HP-UX systems (7.0 HP-UX and later releases). For example, 
>              find / -user pat
>works fine.
>
>Question:
>---------
>On your UNIX system, must -print be used to display the results of
>find? (Please state what flavor of UNIX you have: ULTRIX, SUN, ZENIX, etc.)

On AT&T UNIX System V/x86 Release 4.0 Version 2.1, if you type in:
	find / -user install

You'll get:
	find: no action specified

On other UNIX boxes I've seen, find not give you an error message but just
run for a while and the give you the prompt back.  Since no action was
specified, no output was produced.

Sincerely,

John Ben Urban

djm@eng.umd.edu (David J. MacKenzie) (05/17/91)

>>All the manual pages I've read recommend using -print to display
>>output from find. I've found that -print is unnecessary
>>on my HP-UX systems (7.0 HP-UX and later releases). For example, 
>>              find / -user pat
>>works fine.

In most future Unix systems, -print will be assumed if no actions are
given, because the draft POSIX 1003.2 (shell & utilities) standard
requires that.  In most existing systems, this feature has not been
added yet, and find without an action simply goes through your
directory tree producing no output and wasting CPU time.

--
David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

les@chinet.chi.il.us (Leslie Mikesell) (05/17/91)

In article <2570005@hpcc01.HP.COM> maryhc@hpcc01.HP.COM (Mary Hsia-Coron) writes:
>On your UNIX system, must -print be used to display the results of
>find? (Please state what flavor of UNIX you have: ULTRIX, SUN, ZENIX, etc.)
Yes, for AT&T SysVr3.

>The AT&T System V manual pages say that when find is used with cpio,
>-depth should be used to list files in directories without write
>permission. For example:
>       find / -name report -depth | cpio -ov > /dev/rmt/0h

>On HP-UX systems, find will list files in directories without write
>permission even when -depth is NOT used.

The significant difference is that -depth makes the directory appear
later in the list than its contents.  When cpio sees a directory name
in its input, it stores and entry for that directory in the archive
containing its owner, modes, and similar info.  When restoring files,
it restores the same owner and modes.  However, with the -d option,
it will create any needed directories (with default modes) so you
can write the files there.  If the read-only directory entry comes
later than the files, the read-only mode mode isn't set until the
files are already in place.  If it comes first, you won't be able to
write the files.

Les Mikesell
  les@chinet.chi.il.us

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (05/19/91)

maryhc@hpcc01.HP.COM (Mary Hsia-Coron) writes:

>Do you use the -print and -depth options with the find command?

I use -print, but -depth does not work.

>-print option:
>--------------
>All the manual pages I've read recommend using -print to display
>output from find. I've found that -print is unnecessary
>on my HP-UX systems (7.0 HP-UX and later releases). For example, 
>              find / -user pat
>works fine.

For me, it gives no output.  If that's what I want, then it works fine.

>Question:
>---------
>On your UNIX system, must -print be used to display the results of
>find? (Please state what flavor of UNIX you have: ULTRIX, SUN, ZENIX, etc.)

Yes.  Alternatively "-ls".  Sequent DYNIX.

>-depth option:
>--------------
>The AT&T System V manual pages say that when find is used with cpio,
>-depth should be used to list files in directories without write
>permission. For example:
>       find / -name report -depth | cpio -ov > /dev/rmt/0h
>
>On HP-UX systems, find will list files in directories without write
>permission even when -depth is NOT used.

I suppose it might be nice to have a way to specify NOT to do that.

>Question:
>---------
>On your UNIX system, must find be used with -depth when piping to cpio?
>(Please state what flavor of UNIX you have: ULTRIX, SUN, ZENIX, etc.)

I can pipe anything I want to anything I want.  I've never used "cpio".
When I use "tar" I usually want the whole tree and "tar" does that fine.

>I'm documenting use of find on UNIX systems IN GENERAL and want to make the
>right recommendations about whether to use -print and -depth. I was going
>to recommend that both options not be used.

I'm afraid you documentation would be implementation/vendor specific.

But noting your address domain and job description from your signature,
it sounds as though that might not be a problem.  If you are writing this
specifically for HP-UX users, then of course it is appropriate to deal
with exactly how these things work in HP-UX.  Perhaps you are writing it
to be more generic, in which case you have a big chore ahead of you,
since there are so many inconsistent flavors of everything out there.

>Thanks for any info you can provide!
>Mary Hsia-Coron
>Hewlett-Packard Customer Training
>mary@hpasdd.hp.com

Welcome.
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu   |  Guns don't aim guns at  \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks  |  people; CRIMINALS do!!  /
 \***************************************************************************/