Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!mike From: mike@whuxl.UUCP (BALDWIN) Newsgroups: net.unix Subject: Re: command file HELP Message-ID: <950@whuxl.UUCP> Date: Tue, 4-Feb-86 18:02:02 EST Article-I.D.: whuxl.950 Posted: Tue Feb 4 18:02:02 1986 Date-Received: Wed, 5-Feb-86 04:50:46 EST References: <137@wgivax.UUCP> Organization: AT&T Bell Laboratories, Whippany Lines: 32 > > find / -exec "fgrep this-is-the-string '{}' | awk -F: '{print $1}'" \; > > find / -exec "fgrep this-is-the-string '{}' | awk '{print FILENAME}'" \; Gak! NEITHER of these has any chance of working! The args to -exec are passed to execvp(), so you can't just pass an arbitrary shell cmd to it (this is on System V). Also, {} is only substituted if it is a *separate* arg. If you want to put a pipeline into -exec with the filename, you have to: find dir -exec /bin/sh -c 'prog1 $1 | prog2 $1' sh {} ';' The $1 is used to pull in the {}, and the sh in front of {} is $0. But ANYWAY, that still wouldn't fix it. The $1 in the first one will get substituted because it's in double quotes, and the FILENAME in the second one will print "-", standard input. Anybody ever heard of the -l option to *grep??? Try this: find / -type f -exec grep -l string {} ';' Better yet, if you're on SV you can use xargs to bundle the files up and save considerable amounts of time: find / -type f -print | xargs grep -l string In the future, *please* give examples that at least have a chance of working (i.e., try them once). -- Michael Baldwin (not the opinions of) AT&T Bell Laboratories {at&t}!whuxl!mike