Closed shuxq closed 6 years ago
Thanks for reporting this. The docs are correct. ack should match grep on this. It has been fixed in acks 2.16 and higher, and also works correctly in ack3.
$ garage/ack-2.14 --count '(foo)\s*(bar)' tst.text
2
$ garage/ack-2.16 --count '(foo)\s*(bar)' tst.text
1
$ garage/ack-2.22 --count '(foo)\s*(bar)' tst.text
1
(Aside: It's frustrating that that somehow is not noted in the Changes file)
The documentation on --count claims that it prints "count of matching lines for each input file". This is not consistent with what it actually does.
Naturally, it could be claimed as a bug in the program, if assume that the documentation is actually correct :)
$ cat tst.text foo bar $ ack --count '(foo)\s(bar)' tst.text 2 $ ack --count 'foo\sbar' tst.text 1
$ ack --version ack 2.14 Running under Perl 5.22.1 at /usr/bin/perl
Copyright 2005-2014 Andy Lester.
This program is free software. You may modify or distribute it under the terms of the Artistic License v2.0. $ uname -a Linux feia 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux $ cat /etc/issue Ubuntu 16.04.4 LTS \n \l