Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: Descending directory hierarchy? Keywords: directory list find search Message-ID: <1989Dec2.135436.22689@virtech.uucp> Date: 2 Dec 89 13:54:36 GMT References: <1372@lakesys.lakesys.com> Distribution: usa Organization: Virtual Technologies Inc. Lines: 33 In article <1372@lakesys.lakesys.com>, johnb@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 | +-----------------------------------------------------------------------+