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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
`awk '/expression/{print NR}' file`
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.
ozoCommented:
vi  +`awk '/expression/{print NR}' file`
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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??

ozoCommented:
vi  +`grep -nr grid_row_1 * | awk -F: '{print $2,$1;exit}'`

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dwcroninAuthor Commented:
That did it!!!  Thank you very much Ozo.  This will save me a lot of effort at work.

Thanks!
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.