Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site sauron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!ittatc!dcdwest!sdcsvax!ncr-sd!ncrcae!sauron!wescott From: wescott@sauron.UUCP (Michael Wescott) Newsgroups: net.unix,net.unix-wizards,net.wanted Subject: Re: Need unix command file HELP! Message-ID: <609@sauron.UUCP> Date: Tue, 4-Feb-86 00:41:53 EST Article-I.D.: sauron.609 Posted: Tue Feb 4 00:41:53 1986 Date-Received: Fri, 7-Feb-86 09:26:44 EST References: <245@aero.ARPA> <587@smeagol.UUCP> Reply-To: wescott@sauron.UUCP (Michael Wescott) Organization: NCR Corp., Advanced System Development, Columbia, SC Lines: 29 Xref: watmath net.unix:7029 net.unix-wizards:16671 net.wanted:8089 In article <587@smeagol.UUCP> earle@smeagol.UUCP (Greg Earle) writes: >> We are looking for a utility that can, when given a arbitrary string, >> can locate all occurences of that string anywhere on the system. > >find / -exec fgrep this-is-the-string '{}' \; (UGGGHHH!) > >Warning! Only execute during hours when no one else is in building!! >Guaranteed to tie up CPU for indefinite periods! :@) > >If you only want the file names, this *might* work, I'm not sure ... > >find / -exec "fgrep this-is-the-string '{}' | awk -F: '{print $1}'" \; >(DOUBLE UGGGHHH) I agree, UGGHHH. I know its not on most BSD systems, but it has its uses. I'm talking about `xargs'. For much less cpu usage try: find / -type f -print | grep -v outfile | xargs grep 'pattern' > outfile or some reasonable variation with your favorite grep (or bm). Xargs accumulates arguments from stdin and execs the command and args given for a reasonable number of collected arguments. Hence grep gets executed once per ten or twenty files rather than once per file. I think it's reasonable to expect to search only regular files, hence "-type f" and you better exclude "outfile" unless you use "grep -l". -Mike Wescott ncrcae!wescott