I have this find command to get all the files modified in the last 50 seconds which matchs with the following regex hell\d in the last 1000 characters.
I use tail to get the last 1000 chars in order to speed up the search becouse the files to check are huge (3gb on average).
find /home/ouhma -newermt '50 seconds' -type f |
while read fic; do
if tail -c 1000 "${fic}" | LANG=C LC_ALL=C grep -Pq 'hell\d'; then
echo "${fic}"
fi
done
It is posible to use -exec parameter to replace that ugly loop and to retrieve the result even faster?
This works, but I dont know if its the best way to do it:
find /home/ouhma -newermt '50 seconds' -type f -exec bash -c 'LANG=C LC_ALL=C grep -Pq "hell\d" <(tail -c 1000 "{}") && echo "{}"' \;