you can use
ack -hc ( -h is short for --no-filename ) to get the total.
According to the documentation / man page ack :
-c, --count
Suppress normal output; instead, print the number of matching lines for each input file. If -l is valid, it will only show the number of lines for each file that has the corresponding lines. Without -l some line counts can be zeros.
When combined with -h ( --no-filename ) ack only one total is output.
Here's what worked for me (expanded on @Jordan's answer) -
ack 'pattern' && ack -hc 'pattern'
or better (IMO):
ack 'pattern'; ack -hc 'pattern'
As far as I understand, using && , the second command depends on the first, returning to start; use ; instead, it will run them both, one after the other, independently. In this case, I think that ; more appropriate.
Aaron wallentine
source share