Skip to content

baseprime/srcgrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

srcgrep

Grep through entire source tree based on an expression or string. Will output line file and line number of matched expression.

Example

Searching the source code of all files in the path provided, including file and line number.

$ srcgrep -e '\$path.*' -i -p /var/www/apps/myapp
  /var/www/apps/myapp/myfile.pl:50:    my ($path, $ignore, @regexp, $test, $outfile, @patterns, @excludes);
  /var/www/apps/myapp/myfile.pl:55:    "p|path:s" => \$path,
  /var/www/apps/myapp/myfile.pl:69:    if ("$path") {

Install

npm install -g srcgrep

Usage:

Usage:  srcgrep [OPTIONS] -e PATTERN [-e PATTERN, -e ...]

The output will be in FILENAME:LINE#:LINE format convenient for gvim.

Options:

-h, --help     This usage statement.

-i, --ignore   Ignore case when searching.

-E, --exclude   Exclude filename pattern.

-o, --outfile  Produce an outfile of results in /tmp.  The file
    will be named srcgrep-YYYYmmddHHMMSS.

-t, --test     Do not run the search, but print the command instead.

-p, --path     Path to search.  If left empty, the script will try to
    find the source directory.

-e, --regexp   Search pattern using regular expressions. Additional
    patterns will result in OR searches


EXAMPLES:

To find source files matching either 'File' or 'Foo bar':
srcgrep -e File -e 'Foo bar'

To find files in /tmp with lines starting with Test or test:
srcgrep -i -p /tmp -e '^test'

License

About

Grep through entire source tree based on an expression or string

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages