Path: utzoo!attcan!uunet!wuarchive!usc!ucsd!rutgers!njin!princeton!jonlab!jon From: jon@jonlab.UUCP (Jon H. LaBadie) Newsgroups: comp.unix.questions Subject: Re: grep Summary: Use grep -l to just list file names Message-ID: <871@jonlab.UUCP> Date: 26 Oct 90 16:18:19 GMT References: <1990Oct23.123025.18012@kodak.kodak.com> <2160@sixhub.UUCP> Organization: 4455 Province Line Rd., Princeton, NJ 08540 Lines: 31 In article <2160@sixhub.UUCP>, davidsen@sixhub.UUCP (Wm E. Davidsen Jr) writes: > Lots of people have given you ideas on this, Indeed, but I've seen no one mention the use of the '-l' option to grep. The original poster wanted to locate the "files" that contained the pattern, not the "lines" containing the pattern. By using the -l option, grep will simply output a list of the file names. An added benefit is that grep will skip the rest of the current file once it finds a match. > ... I'll just add that if you > have a large number of non-text files in this structure, you can save > time by using the "file" command to identify the text files. > > Something like: > > $ find . -type f -print | xargs file | grep " text" | > > sed 's/:.*$//' | xargs grep PATTERN /dev/null > Just a comment specific to AIX 3.1. The common practice of looking for text files using file * | grep " text" does not work properly as some output messages contain the word "text" even though the file is a binary or data file. For example, one message I remember is "data or NLS text". -- Jon LaBadie {att, princeton, bcr, attmail!auxnj}!jonlab!jon