[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

which editor will open files in succession

I am looking for the easy way to examine grep finds.  I often grep for an expression in a bunch (~30) of programming files.  I then go through the list of results and look at each of them to see if they are important to me.  Ozo (EE guy) told me yesterday how to use awk to print out the line number and file name of all of the files that have an expression that I'm looking for.  I thought that I could pipe this into vi and automatically look through all of the files to see if one has what I was looking for.  Unfortunately vi only goes to the line number for the first file in a list.  Does anyone know how to automatically look through a bunch of files that have the expression that you're looking for in them?  I'm not picky about which editor I'm using.

Thanks
0
dwcronin
Asked:
dwcronin
1 Solution
 
ozoCommented:
emacs [+linenumber] file [+linenumber] file ...
0
 
ahoffmannCommented:
vi +42 file
vi +/pattern/ file
0
 
dwcroninAuthor Commented:
ahoffmann,
Yes you can do that to get to line 42 of "file" or to find "pattern" in "file" but the problem is that I wanted to automatically go to specific lines of various file.  I thought that I could use:

vi +line_file1 file1 +line_file2 file2

It turns out that vi will only go to the specified line of file1.  For the rest of the files, it goes to the beginning.  I'm going to go check out Ozo's answer.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fridomCommented:
run grep within Emacs and you get a buffer with all results. Just go into that buffer and klick on the proper place and emacs will go there.

Regards
Friedrich
0
 
ahoffmannCommented:
# if you're not adicted to emacs: quick&dirty and to be improved in many ways:)
grep -n -s pattern list of files|awk -F: '{print "vi +"$2" "$1}'|sh
# or
gawk /pattern/'{print "vi +"FNR" "FILENAME}' list of files|sh
0
 
Prashant SabnekarAVPCommented:
One more new editor is there called Anjuta, where you can use its menu to find a particular string in multiple files.

Regards
Prashant Sabnekar
0
 
Prashant SabnekarAVPCommented:
anjuta.sourceforge.net
This is the URL to the Anjuta editors Home Page

Regards
Prashant Sabnekar
0
 
ahoffmannCommented:
> .. menu to find a particular string in multiple files.
that's what vi can do since roughly 30 years with a simple key-stroke
prashantsabnekar, no offence but SCNR ;-)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now