I believe ack
magically* knows that *.py
files are Python source code, and will show line numbers and colorization for source code files but not for plain old data files like *.data
. This is considered a feature, not a bug.
If you want a predictable, composable replacement for grep
, try grep
. ;)
* – It's not really magic, of course; it's configurable in your .ackrc
file. Run ack --help-types
for more information.
EDIT: I'm wrong! It's not because of the difference between .py
and .data
; it's because of the difference between ack pattern f1
and ack pattern f1 f2 ...
. In the latter case, ack
will print which of the files f1 f2 ...
contained the matches; in the former (single file) case, ack
will behave more like grep
.
To fool ack
into producing line numbers even for a single file, add a fake file on the end of the line. For Cygwin, you could probably do
perl D:\ack-standalone.pl "5 " NeedMoreCoffee_n5_*.data /dev/null
For Windows, maybe this still works:
perl D:\ack-standalone.pl "5 " NeedMoreCoffee_n5_*.data NUL
(that's literally the letters N U L, which is how Windows spells /dev/null
; see also CON, LPT1, etc).