Since you will have to open every file, you can also use a tool build for this specific task. Use grep
:
We have 100000 files to look at.
% ls -l *.txt | wc -l
100000
They contain Vestibulum
.
% grep Vestibulum 1.txt
Aenean commodo ultrices imperdiet. Vestibulum ut justo vel sapien venenatis tincidunt.
euismod ultrices facilisis. Vestibulum porta sapien adipiscing augue congue id pretium lectus
Count the files containing Vestibulum
, time this.
% time grep -l Vestibulum *.txt | wc -l
100000
grep --color=auto -l Vestibulum *.txt 0,28s user 0,25s system 99% cpu 0,537 total
wc -l 0,00s user 0,01s system 1% cpu 0,537 total
As you see, this takes only have a second on my machine.