Finding unique occurance of a string in .cs files

  • Thread starter Thread starter Aaron Prohaska
  • Start date Start date
A

Aaron Prohaska

Does anyone know of a good way to search through all the code files to
find a string. The problem I'm trying to solve is that I would like to
get a list of all the stored procedures being used in my projects.
Though I don't want a complete list of all the occurrences, I want to
get a unique list of stored procedures. Anyone have any idea's?

thanks,

Aaron
 
there are some old unix utilities that I use: find, grep, sed and uniq.

These are available in the Microsoft Services For Unix (add on product to
Windows). They are also available on Windows in other packages. Like Cygwin
(from Redhat), MKS, and maybe some other freebies.

What I do is
find . -name "*.cs" -exec grep KEYWORD {} nul ;

and you can pipe that through sed and then uniq to get what you want. It
basically says, find all the c# files, search for KEYWORD in those files,
and print the line (and filename) that matches. By sending the output into
sed (stream editor) you can parse out the lines you want using regular
expressions. Uniq then removes duplicates, so you have the result you want.

Sorry if this is all sounds obscure or unapproachable, but the topic of text
processing utilities is a broad one, and I don't know how to give you a
10-second overview of find, grep, uniq, sed, etc.

-Dino
Microsoft
 
Hello Dino,

This is a good start to what I need. I didn't know what utilities I
needed and what to pipe through what. Now I just have to get the apps
like grep to use.

thanks,

Aaron
 
Back
Top