From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Thu, 10 Feb 2005 09:59:41 -0500 From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] tip o' the day In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1108020075.2762.2.camel@pallas.invalid> Topicbox-Message-UUID: 066e5f76-ead0-11e9-9d60-3106f5b1d025 > fn gn { grep -n $* /dev/null } > Grep, but force listing of filename:lineno so you > can click on an entry to jump to it in an editor. > > fn g { grep -n $* *.[chsyl] /dev/null } > gn on all sources in the current directory rob and i use this as /bin/g. it handles both of these: % cat /bin/g #!/bin/rc flags=() while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){ flags=($flags $1); shift } if(~ $1 --) shift switch($#*){ case 0 echo 'usage: g [flags] pattern [files]' >[1=2] exit usage case 1 pattern=$1 files=(`{ls *.[bcChm] *.cc *.py *.tex *.ms *.java >[2]/dev/null}) case * pattern=$1 shift files=($*) } grep -n $flags -- $pattern $files /dev/null % > (how about a plumber command that ran grep -n on the files > in the current directory and the include directory? Then > you could plumb words to it in acme with mouse chording to > quickly crossreference keywords in the src tree. I tried > goofing with that once but failed pretty miserably). i don't see why you'd involve the plumber. just write a script. i find i almost never want to grep both local files and /sys/include. i either run g or sig. % sig memmove void* memmove(void *s1, void *s2, long n) % russ