Descending directory hierarchy?

Conor P. Cahill cpcahil at virtech.uucp
Sun Dec 3 00:54:36 AEST 1989


In article <1372 at lakesys.lakesys.com>, johnb at lakesys.lakesys.com (John C. Burant) writes:
> I've been thinking about the find command on SysV's... the one that makes you
> type find / name [filename] -print to find files, and only finds files with
> the exact filename specified... and I've been thinking about writing a program
> that will act like the BSD find... it list all files with the phrase you look
> for in the filename... (like if I looked for t, I'd get a lot of files listed)
> 
> Which brings me to the question: Is there a way to descend the directory 
> hierachy into every directory, or do I have to write a routine to do that?

First of all the -name parameter to find acts the same way in both system V
and in BSD.  In either system, if you did a "find / -name t -print" you \
would only find files that are named 't', not files that have a 't' in thier
names.  

To search for a file with a 't' in the name, you need to do the following:

	find / -name "*t*" -print..

Again, this is the same for both system V and BSD.


Second, System V has an ftw(3) "File Tree Walk" routine that can be used 
to descend the entire directory hierarchy.




-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list