utility idea

Giorgos Keramidas keramida at ceid.upatras.gr
Thu Oct 16 14:10:41 PDT 2003


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



More information about the freebsd-questions mailing list