gefuchs@skolem.uucp (Gill E. Fuchs) (05/08/89)
how would one search for a filename in a directory hierarchy? supose i know there exists a file call gugu but i cannot remmember in which sub-directory? i was thinking of using : find . -name 'gugu' -print but obviously that only works for the current directory how would one make that a recursive search, something a la ls -R still in search of gugu gill
ghe@nucthy.physics.orst.edu (Guangliang He) (05/08/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: > >how would one search for a filename in a directory hierarchy? > >supose i know there exists a file call gugu but i cannot remmember >in which sub-directory? > >i was thinking of using : > find . -name 'gugu' -print >but obviously that only works for the current directory >how would one make that a recursive search, something a la ls -R > >still in search of gugu >gill I don't know what flavor of UNIX you are using. On most unix systems I know of(Sys V and BSD), find(1) does search recursively. Check your manual see if it search recursively or not. ----------------------------------------------------------------------- | USMAIL: Guangliang He | INTERNET: ghe@PHYSICS.ORST.EDU Department of Physics | ghe@jacobs.CS.ORST.EDU Oregon State University | BITNET: hegl@orstvm.bitnet Corvallis, OR 97331 | PHONE: (503) 754-4631 | -----------------------------------------------------------------------
lawrence@its.rpi.edu (David Lawrence) (05/08/89)
In article <1530@cmx.npac.syr.edu> gefuchs@skolem.uucp (Gill E. Fuchs) writes:
GEF> supose i know there exists a file call gugu but i cannot remmember
GEF> in which sub-directory?
GEF> i was thinking of using :
GEF> find . -name 'gugu' -print
GEF> but obviously that only works for the current directory
Uh .... obviously not, if you read the manual page for find. find is
recursive; in fact, getting it to stop being recursive is a real pain
(you can only prune directories based on name or pattern; pruning
based on level would be a welcome addition to find). You should have
tried that, it would work.
Dave
--
tale@rpitsmts.bitnet, tale%mts@itsgw.rpi.edu, tale@pawl.rpi.edu
jik@athena.mit.edu (Jonathan I. Kamens) (05/08/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: >i was thinking of using : > find . -name 'gugu' -print >but obviously that only works for the current directory >how would one make that a recursive search, something a la ls -R No, actually, this "obviously" will do a recursive search, which is (apparently) what you want. From the man page for find(1): SYNOPSIS find pathname-list expression find pattern DESCRIPTION In the first form above, find recursively descends the directory hierarchy for each pathname in the pathname-list (i.e., one or more pathnames) seeking files that match a boolean expression written in the primaries given below. And here's an example from actual usage: % find . -name delete -print ./vax/delete ./vax/delete/delete ./Mail/delete ./rtbin/delete ./vaxbin/delete ./rt/delete ./rt/delete/delete ./src/delete ./NeXTbin/delete ./NeXT/delete ./NeXT/delete/delete Jonathan Kamens USnail: MIT Project Athena 410 Memorial Drive, No. 223F jik@Athena.MIT.EDU Cambridge, MA 02139-4318 Office: 617-253-4261 Home: 617-225-8218
andre@targon.UUCP (andre) (05/08/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: >i was thinking of using : > find . -name 'gugu' -print >how would one make that a recursive search, something a la ls -R try find . -name '*gugu' -print -- ~----~ |m AAA DDDD It's not the kill, but the thrill of the chase. ~|d1|~@-- AA AAvv vvDD DD Segment registers are for worms. ~----~ & AAAAAAAvv vvDD DD ~~~~~~ -- AAA AAAvvvDDDDDD Andre van Dalen, uunet!mcvax!targon!andre
ray3rd@ssc-vax.UUCP (Ray E. Saddler III) (05/08/89)
In article <1530@cmx.npac.syr.edu>, gefuchs@skolem.uucp (Gill E. Fuchs) writes: > > how would one search for a filename in a directory hierarchy? > > i was thinking of using : find . -name 'gugu' -print > but obviously that only works for the current directory / /____wrong! > how would one make that a recursive search, something a la ls -R Find *does* a recursive search [at least on BSD 4.2 & 4.3, and SYSV 3.1]. Use 'find . -name gugu -print'. It will [should] work unless your flavor or *ix is unusual enough to *not* recursivly search. -- Ray E. Saddler III | __ __ __ __ | UseNet Boeing Aerospace | / / / // //| // | uw-beaver!ssc-vax!ray3rd P.O. Box 3999 m.s. 3R-05 | /-< / //- // |// _ | PhoneNet Seattle, Wa. 98124 USA | /__//_//__ // //__/ | 1+206-657-2824
gwyn@smoke.BRL.MIL (Doug Gwyn) (05/08/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: > find . -name 'gugu' -print >but obviously that only works for the current directory Not so obvious to me..
dans@hplsla.HP.COM (Dan Siler) (05/09/89)
Here's a script called "ff" that I use to find files. #!/bin/sh if [ "$#" -ne 2 ] then echo "\nusage: ff directory file_set\n" exit fi find $1 \( -name $2 \) -exec ll -o {} \; exit _________________________________________________________________________ | | | Dan Siler unix: dans%hplsla@hplabs.hp.com hplabs!hplsla!dans | | Hewlett Packard hpdesk: DAN SILER/HPA100/15 | | Lake Stevens Instrument Division, ms:380 at&t: (206) 335-2178 | | 8600 Soper Hill Road; Everett, WA 98205-1298 telnet: 1-335-2178 | |_________________________________________________________________________|
guy@auspex.auspex.com (Guy Harris) (05/09/89)
>how would one search for a filename in a directory hierarchy? With the "find" command. >supose i know there exists a file call gugu but i cannot remmember >in which sub-directory? find . -name gugu -print >i was thinking of using : > find . -name 'gugu' -print You got it... >but obviously that only works for the current directory ...but obviously you haven't RTFM; "find" does *NOT* search only the current directory - the whole point of "find" is that it *does* search recursively.
gph@hpsemc.HP.COM (Paul Houtz) (05/10/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: > find . -name 'gugu' -print >but obviously that only works for the current directory No. This will descend the directory tree from current directory thru all subdirectories. If you want to start at root, enter: find / -name 'gugu' -print
gandalf@csli.Stanford.EDU (Juergen Wagner) (05/10/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: > >how would one search for a filename in a directory hierarchy? ... >i was thinking of using : > find . -name 'gugu' -print >but obviously that only works for the current directory >how would one make that a recursive search, something a la ls -R "find" *WILL* perform a recursive search unless it is told otherwise. TFM mentions that "find" searches the tree starting at the directories listed (in this case: starting at "."). That's the whole point why "find" is used. -- Juergen Wagner gandalf@csli.stanford.edu wagner@arisia.xerox.com
daveh@marob.MASA.COM (Dave Hammond) (05/11/89)
In article <1530@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu writes: >how would one search for a filename in a directory hierarchy? >[...] >i was thinking of using : > find . -name 'gugu' -print ^^^ >but obviously that only works for the current directory Try: find / -name 'gugu' -print Find recursively searches from the base directory named through all subdirectories. Therefore, if you specify "/" as the base directory, the entire filesystem will be searched. -- Dave Hammond daveh@marob.masa.com
ram@attcdso.UUCP (R. Meesters, Tech Support, AT&T Canada DSO ) (05/15/89)
In article <1530@cmx.npac.syr.edu>, gefuchs@skolem.uucp (Gill E. Fuchs) writes: > > how would one search for a filename in a directory hierarchy? > > i was thinking of using : > find . -name 'gugu' -print > but obviously that only works for the current directory > how would one make that a recursive search, something a la ls -R > How bout using the following... find /<sub-dir> -name 'gugu' -print This will search from the named sub-directory upwards through the directory tree...providing, of course, you have appropriate permissions. I often use find / -name firp -print to find files when I don't know where the heck they exist. -- ------------------------------------------------------------------------------ Richard Meesters | AT&T Data Service Operations | "Calling YOU stupid would Toronto, Ontario | be an insult to stupid people" ...attcan!nebulus!attcdso!ram | - A Fish Called Wanda ------------------------------------------------------------------------------
bph@buengc.BU.EDU (Blair P. Houghton) (05/17/89)
In article <167@attcdso.UUCP> ram@attcdso.UUCP (R. Meesters, Tech Support, AT&T Canada DSO ) writes: >In article <1530@cmx.npac.syr.edu>, gefuchs@skolem.uucp (Gill E. Fuchs) writes: >> >> how would one search for a filename in a directory hierarchy? > >I often use find / -name firp -print to find files when I don't >know where the heck they exist. Some versions of find(1) (notably the one with this here Umax) are implemented to look in a database (usually stored in /usr/lib/find.code) that is updated periodically with the names of all world-accessible files on the system. When invoking find(1), you simply use find pattern which gives the same output as find / -name pattern -print except that any files written since the database was updated (weekly, likely) won't be available, but the amount of time it takes to get the whole set of pattern-matching filenames is miniscule compared to how long a regular directory-search takes. --Blair "I think it's alright..."
markk@sigma.UUCP (Mark Kimmerly) (05/18/89)
In article <1530@cmx.npac.syr.edu>, gefuchs@skolem.uucp (Gill E. Fuchs) writes: > how would one search for a filename in a directory hierarchy? > i was thinking of using : > find . -name 'gugu' -print > but obviously that only works for the current directory Check your manual again. The command you were thinking of using should work just fine. If find did NOT recursively search subdirectories, it would be pretty useless. -- Mark Kimmerly markk@sigma.UUCP Summation Inc. 1-206-823-7964
rae98@wash08.UUCP (rae98) (05/25/89)
In article <1530@cmx.npac.syr.edu>, gefuchs@skolem.uucp (Gill E. Fuchs) writes: > > how would one search for a filename in a directory hierarchy? > > i was thinking of using : > find . -name 'gugu' -print > but obviously that only works for the current directory > how would one make that a recursive search, something a la ls -R No, actually, that find command will find a file/directory anywhere from . on down through all subdirs whose name is gugu. -- ------------------------------------------------------- UUNET: uunet!wash08!rae98 should work. BITNET: I don't know...can you tell me? UUCP: rae98@wash08.UUCP does this work?