Path: utzoo!attcan!uunet!bu.edu!rpi!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!nikhefh!a20 From: a20@nikhefh.nikhef.nl (Marten Terpstra) Newsgroups: comp.unix.questions Subject: Re: grep Keywords: Use find, and grep Message-ID: <1027@nikhefh.nikhef.nl> Date: 26 Oct 90 13:10:47 GMT References: <1990Oct23.123025.18012@kodak.kodak.com> <1990Oct23.143247.5639@lgc.com> <490@epicb.com> Sender: terpstra@nikhef.nl (Marten Terpstra) Reply-To: a20@nikhefh.nikhef.nl (Marten Terpstra) Organization: Nikhef-H, Amsterdam (the Netherlands). Lines: 30 In article <1990Oct23.123025.18012@kodak.kodak.com> tiefel@sunshine.Kodak.COM (Lenny Tiefel) writes: >I have a main directory with hundreds of subdirectories, >and I want to find a file with a particular string, say "xyz" >The grep command only works in one directory at a time. Is there >a way of searching my whole directory structure to find a file >with a particular string? A few months or so ago some people wanted to de the same thing. After a long debate of the best solutions this is the one that should work best : --start of script-- #! /bin/sh # Recgrep : a version of grep which recursively searches every directory # within current directory. # Usage : recgrep find . -type f -exec grep $1 {} /dev/null \; --end of script-- Marten -- " Quidquid Latine Dictum Sit, Altum Viditur. " ( Whatever is said in Latin, sounds profound ) ------------------------------------------------------------------------------- Marten Terpstra National Institute for Nuclear Internet : terpstra@nikhef.nl and High Energy Physics Oldie-net: {...}mcsun!nikhefh!terpstra (NIKHEF-H) PO Box 1882, 1009 DB Phone-net: +31 20 592 5102 Amsterdam, The Netherlands -------------------------------------------------------------------------------