use awk to view results of a grep command

Experts,
I forget awk - if something else (perl) works better, then tell me how to do this in perl.  I grep for a certain expression and I would like to use vi to look at each of the results.  I know that "vi +5 afile" will run vi and put you on line 5 of "afile".  Is there some command line that I can tyype to automate looking up files.  Ignoring syntax (which is wrong):

            vi  +`awk line number and filename expression`

I would like this to put me at the proper line on each of the relevant files where the expression I am grepping for is found.
dwcroninAsked:
Who is Participating?
 
ozoCommented:
vi  +`grep -nr grid_row_1 * | awk -F: '{print $2,$1;exit}'`
0
 
ozoCommented:
`awk '/expression/{print NR}' file`
0
 
dwcroninAuthor Commented:
I'm back in windows for a little bit but - it doesn't look like that will do it.  "vi" is not mentioned anywhere and where is the " +line number".  The point was to scan all of the files in a directory for an expression and then to have vi open up each file at the proper line.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
ozoCommented:
vi  +`awk '/expression/{print NR}' file`
0
 
dwcroninAuthor Commented:
That doesn't seem to do anything.  How about:

grep -nr grid_row_1 *

will print out all of the files along with line numbers that contain the expressionn "grid_row_1".  I would like to use awk to take this information and then use "vi +........" to go to a specific line number in  a specific file.  Any guesses there??

0
 
dwcroninAuthor Commented:
That did it!!!  Thank you very much Ozo.  This will save me a lot of effort at work.

Thanks!
0
 
dwcroninAuthor Commented:
I thought that I should add this comment: this doesn't quite work the way that I was wanting.  Ozo got the awk command to give the output that I wanted, but vi doesn't edit the files the way that I was hoping.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.