Silver finder can get PATTERN from file?

There are 84 PATTERNs to check, I store them in the pattern.txt file name .

Is a silver finder (also called Ag) able to get these patterns from pattern.txt ?

grep has -foptions for reading a pattern from a file, but nothing is said about it in the silver finder's manual page.

+4
source share
1 answer

No, in ag there is no similar option -f. A simple approach is to use a loop to pass patterns to ag; for example, you could use a while loop to read patterns like this:

while read pattern; do ag "$pattern" -G '.*.txt' ; done < patterns.txt

GNU ag. ag :

< patterns.txt | parallel 'ag --filename --parallel --color "{}" '

, , , ag, . , , (https://www.gnu.org/software/parallel/man.html). , 84 .

+3

Source: https://habr.com/ru/post/1667342/


All Articles