Xref: utzoo comp.unix.wizards:9020 comp.unix.questions:7347 Path: utzoo!attcan!uunet!husc6!think!ames!oliveb!intelca!mipos3!omepd!andyc From: andyc@omepd (T. Andrew Crump) Newsgroups: comp.unix.wizards,comp.unix.questions Subject: Re: grep replacement Message-ID: <3503@omepd> Date: 31 May 88 16:03:32 GMT References: <7882@alice.UUCP> <5630@umn-cs.cs.umn.edu> <6866@elroy.Jpl.Nasa.Gov> <4524@vdsvax.steinmetz.ge.com> <1036@cfa.cfa.harvard.EDU> Reply-To: andyc@omepd.UUCP (T. Andrew Crump) Organization: Intel Corp., Jones Farm Lines: 14 In article <1036@cfa.cfa.harvard.EDU> wyatt@cfa.harvard.EDU (Bill Wyatt) writes: >> There have been times when I wanted a grep that would print out the >> first occurrence and then stop. > >grep '(your_pattern_here)' | head -1 Yes, but it forces grep to search a whole file, when what you may have wanted was at the beginning. This is inefficient if the "file" is large. A more general version of this request would be a parameter that would restrict grep to n or less occurrences, maybe 'grep -N #'. -- Andy Crump