ack 3.1.0 allows searching ranges of lines in a file
The new version v3.1.0 of the greplike code search tool ack has been released. It now allows the user to search through ranges of lines in a file, rather than the entire file.
For example, if you wanted to search for all occurrences of “google” in
HTML files, but only in the <head>
part of the file, you’d use:
ack google --html --range-start='<head>' --range-end='</head>'
There can be more than one range in each file. For example, if your PHP
functions all look like this, with function
and the closing brace always
flush left:
function nuke() {
print "launching nukes";
}
then you could search for only those occurences of “print” within a function like this:
ack print --php --range-start='^function ' --range-end='^}'
For more, see “Matching in a range of lines” in the ack manual.
See the ack install page for where to get and how to install ack.
My thanks to those who helped with this release, including Bill Ricker, Rob Hoelz, Shawn Carroll and Salomon Smeke.