utility idea

Gary Kline kline at thought.org
Thu Oct 16 14:49:48 PDT 2003


On Thu, Oct 16, 2003 at 11:45:44PM +0300, Giorgos Keramidas wrote:
> On 2003-10-16 10:18, Gary Kline <kline at thought.org> wrote:
> > Is there an existant utility (script) that captures the output of
> > grep -n and, using vi then presents the user with the list of files
> > that are brought at the first point where the string was seen.
> > E.g, if I'm recursively searching for the string "ncount" and find
> > several files, the script would queue up each file.
> >
> > (I seem to remember a debugging script that would do something like
> > this using the err output from cc, but this was years and years ago.)
> >
> > Clues welcome, people,
> 
> You can probably hack something around grep/awk, i.e.:
> 
> : g:/etc/mail> grep -n 'otenet' *
> : gothmog.cf:154:DSmail.otenet.gr
> : gothmog.mc:8:define(`SMART_HOST', `mail.otenet.gr')
> : sendmail.cf:154:DSmail.otenet.gr
> :
> : g:/etc/mail> grep -n 'otenet' * | awk -F: '{print "vi +"$2,$1}'
> : vi +154 gothmog.cf
> : vi +8 gothmog.mc
> : vi +154 sendmail.cf
> 
> Filter the output of that last pipeline through sh(1) and vi will fire
> up as many times as necessary:
> 
> : g:/etc/mail> grep -n 'otenet' * | awk -F: '{print "vi +"$2,$1}' | sh
> 
> HTH, Giorgos
> 
	
	Howdy!

	Yes, this helps.  I remember hacking something vaguely along this
	line in C (when my knoweldge of perl was virtually nil).
	Can't find the program!

	thanks for the ideas,

	gary


-- 
   Gary Kline     kline at thought.org   www.thought.org     Public service Unix



More information about the freebsd-questions mailing list