unix - Possible to return number of matches per line of a regex file using `grep -f regexfile queryfile`? -


i'm wondering if there simple way transform grep command such as

grep -c -f regex.txt file.txt

to return total number of matched lines in file.txt each line of regex.txt, instead of sum of matched lines found patterns in regex.txt above command does.

my current method of handling use xargs (or gnu parallel interchangeably):

cat regex.txt | xargs -i{} grep -c {} file.txt

can grep in 1 fell swoop?

grep -o -f regex.txt | sort | uniq -c 

Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -