Re: [CsMain] Searching CS code tree using grep and avoid .svn directories question
Christian Van Brussel <[email protected]> Fri, 20 Jan 2012 14:58:27 +0100
| Newsgroups | gmane.comp.graphics.crystalspace.general |
|---|---|
| Organization | UCL - TELE |
| Message-ID | <1327067907.1954.82.camel@scylla> |
On Tue, 2012-01-10 at 08:08 +0100, res wrote:
> Once you started to actually modify source files you probably want to
> exclude backup files as well; to accomplish that, pass ‘--exclude=*~’ on
> the command line.
I do the file selection by using the 'find' command instead. I also use
the 'H' switch of grep/egrep in order to get the file name along with
the relevant code line:
find . -name "*.cpp" -exec egrep -H "csMin.\(|csMax.\(" "{}" ";" | less
I put that in a small script (in attachment of this mail), and it's even
easier:
_ffind "csMin.\(|csMax.\("
or more explicitely:
_ffind . cpp "csMin.\(|csMax.\("
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[email protected]?subject=unsubscribe
_ffind.sh
(application/x-shellscript, 795 B)
#!/bin/bash
if [ -z $1 ]; then
echo "ERROR: Forgot search criterion as argument"
echo ""
echo "Usage:"
echo ""
echo "_ffind <path> <format> <criterion>"
echo "Search for 'criterion' in all files of the format 'format' within the given 'path'"
echo ""
echo "_ffind <path> <criterion>"
echo "Search for 'criterion' in all cpp files within the given 'path'"
echo ""
echo "_ffind <criterion>"
echo "Search for 'criterion' in all cpp files within the current directory"
else
if [ -z $2 ]; then
find . -name "*.cpp" -exec egrep -H "$1" "{}" ";" | less
else
if [ -z $3 ]; then
find $1 -name "*.cpp" -exec egrep -H "$2" "{}" ";" | less
else
find $1 -name "*.$2" -exec egrep -H "$3" "{}" ";" | less
fi
fi
fi