I don't know ack
but with tools such as grep
I typically use:
( find . -maxdepth 1 -print ; find . -mindepth 2 -print ) | xargs -n 50 -exec grep TXT
The part between (
and )
ensures that first the files at level 1 are listed and after that those at 2 and deeper (you can vary). xargs
feeds the file names per 50 to grep
.
Of course it depends on which variant of find
is available on your platform. If running something from 30 years ago, you will need to use something like sorting on the number of forward slashes.
ag
, which is about 5–10 times faster thanack
and provides no drawbacks. Combined with switching to SSD I haven’t had the problem since.