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
Post a Comment