Find instances of ToDo in source files

ack -r Client .

Find number of files where string ToDo occurs

ack -l 'ToDo' sourceDirectory | wc -l
  12

Find string "FooBar" in any .* files ignoring certain directories

$ pwd
/User/lumeng
$ ack --type=matlab --ignore-dir={subdir1,subdir2} "\"FooBar\""

Remarks:

  • /User/lumeng/subdir1, /User/lumeng/subdir2 are not searched;
  • --type=matlab specifies that files with file name extension .m is searched; Check ack --help=type for complete list of types;

Find Plot in Mathematica and related source code files

ack --type-add=wolfram:ext:.m,.nb,.cdf,.mt,.wl,.wlt --wolfram Plot

Optionally, add --type-add=wolfram:ext:.m,.nb,.cdf,.mt,.wl,.wlt to a ${HOME}/.ackrc and ue

ack --wolfram Plot
ack --nowolfram Plot

blog comments powered by Disqus