command file HELP (flame on)

mo at wgivax.UUCP mo at wgivax.UUCP
Tue Feb 4 22:23:06 AEST 1986


> from ram at wgivax
>> 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)
>> -- 
> Or maybe...
> find / -exec "fgrep this-is-the-string '{}' | awk '{print FILENAME}'" \;

--------------------------- FLAME ON! ---------------------------------------

WILL YOU PEOPLE PLEASE RTFM BEFORE MAKING SUGGESTIONS ABOUT HOW TO HELP
WITH PROBLEMS?  ADMITTEDLY THE FIRST WILL WORK, BUT WILL PRINT OUT THE
FILE NAME FOR EVERY OCCURRENCE OF THE STRING IN A GIVEN FILE!  THE SECOND
"SUGGESTION" WILL PRINT OUT "-" FOR EVERY OCCURRENCE OF THE STRING IN
EVERY FILE IT IS FOUND IN!  (-: WHAT A HAPPY SUPRISE FOR THE PERSON WHO
WAITS 12 HOURS FOR IT TO RUN, REDIRECTING IT INTO A FILE, TO FIND THAT
ALL THE WORK WAS A WASTE :-)  NOTE THAT BOTH SUGGESTIONS WOULD BE RUNNING
NUMEROUS AWKS, ADDING AWK'S STARTUP COSTS FOR EACH AND EVERY FILE, DIRECTORY,
DEVICE, ETC. IN THE SYSTEM (-: MAYBE 12 HOURS IS TOO LOW AN ESTIMATE, MAYBE
12 DAYS WOULD BE BETTER, UNLESS YOU'RE RUNNING A CRAY OR AN IBM-PC :-)

--------------------------- FLAME OFF! --------------------------------------

OK, now that I have that out of my system, I will re-post a solution which
I have fully TESTED (-: interesting idea, to test something before offering
it as a solution, no? :-).

find / -type f -exec fgrep -l "string" {} \;

caveat emptor: (let the buyer beware, for those without high school latin)

ALWAYS TRY SOMETHING LIKE THIS ON A SMALL SUBSET OF THE FILES WHICH ARE TO
BE INCLUDED!  LIKE: "find ~ ..."



More information about the Comp.unix mailing list