Path: utzoo!attcan!uunet!husc6!rutgers!mtunx!mtuxo!mtgzy!mtgzz!avr From: avr@mtgzz.UUCP (XMRP50000[jcm]-a.v.reed) Newsgroups: comp.unix.questions Subject: Re: grep replacement Summary: Use "|cut". After all, this is UNIX! Message-ID: <4139@mtgzz.UUCP> Date: 31 May 88 16:26:55 GMT References: <7882@alice.UUCP> <2450011@hpsal2.HP.COM> Organization: AT&T, Middletown NJ Lines: 13 In article <2450011@hpsal2.HP.COM>, morrell@hpsal2.HP.COM (Michael Morrell) writes: > Also, what line number it was found on. > grep -n does this, but I'd like to see an option which ONLY prints the line > numbers where the pattern was found. # In ksh's $ENV - otherwwise use a shell script: function lngrep { if [ "$#" = '1' ] then grep -n $@ | cut -f1 -d: else grep -n $@ | cut -f1,2 -d: fi } Adam Reed (mtgzz!avr)