find command

Glenn Fowler[drew] gsf at ulysses.homer.nj.att.com
Sat Dec 2 00:16:08 AEST 1989


In article <4343 at helios.ee.lbl.gov>, envbvs at epb2.lbl.gov (Brian V. Smith) writes:
> It seems as though the Ultrix and SunOs find ALWAYS use a *depth-first*
> search and there is no option to do a *breadth-first* search.
> 
> Anyone out there know if it is possible to do a breadth-first search with find
> under Ultrix or SunOs?  I presume BSD is the same.

the -depth option is mis-named - BSD and ATT find always use depth-first-search
by default find does a pre-order DFS - a directory is seen before its children
-depth (when available) turns on a post-order DFS - a directory is seen
after its children have been processed

	$ find . -print		# pre-order
	.
	./first-child
	...
	./last-child

	$find . -depth -print	# post-order
	./first-child
	...
	./last-child
	.

just think of -depth as -post
a breadth-first directory traversal would be resource intensive
-- 
Glenn Fowler    (201)-582-2195    AT&T Bell Laboratories, Murray Hill, NJ
uucp: {att,decvax,ucbvax}!ulysses!gsf       internet: gsf at ulysses.att.com



More information about the Comp.unix.questions mailing list