I want to search multiple patterns
in a directory
containing recursive directories
and files
.
I know command for grep
which is as follows
grep -e '(pattern1)|(pattern2)'
or
grep -r -E 'string1|string2|string3' /var/www/http
What is the command for that using ack
or ag
?
This should be enough:
ack -R 'string1|string2'
As -R
is the default, you can omit it:
ack 'string1|string2'
From man ack
:
-r, -R, --recurse
Recurse into sub-directories. This is the default and just here for compatibility with grep. You can also use it for turning --no-recurse off.
If you want to get the pattern from a file, say /path/to/patterns.file, you can use:
ack "$(cat /path/to/patterns.file)"
or equivallently:
ack "$(< /path/to/patterns.file)"
I cannot find an exact equivalent to grep -f
.