How to do max-depth search in ack and grep

ackgrep

Is there any way to tell ack to only search for text on the current folder? (or specify a max-depth level?) And with grep?

Best Answer

Use -n for no-recurse:

$ ack -n foo

grep is not recursive by default, and you should use the -r flag only if you want a recursive search.

You can search the current directory with grep as follows:

$ grep -- foo *