We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

which editor will open files in succession

dwcronin
dwcronin asked
on
Medium Priority
215 Views
Last Modified: 2013-12-26
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
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015
Commented:
emacs [+linenumber] file [+linenumber] file ...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
vi +42 file
vi +/pattern/ file
dwcronindisabled

Author

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.
fridomCEO/Programmer
CERTIFIED EXPERT

Commented:
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
# 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
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
anjuta.sourceforge.net
This is the URL to the Anjuta editors Home Page

Regards
Prashant Sabnekar
> .. 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 ;-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.