Grep all files in a directory and print matches with file name
- by javanix
I have a list of log files that I create as part of a video encoding script that I wrote.
I would like to search all of them and print out certain statistics from the encode - how fast they were encoded, what settings were used, etc.
I can search for the average framerate in one file via this 1 liner:
cat ${filename} | grep average
which outputs:
work: average encoding speed for job is 23.211176 fps
and search for the ratefactor:
cat ${filename} | grep RF
I would like to search all files in the directory and print off one, or prefereably both pieces of information along with the filename. Is there any way I can use find or grep to get this in a one-liner, or do I need to write a script?
I would like output like this:
/home/javanix/filename.log
<RF line>
<average line>
I would like this to either work using FreeBSD 9 or Ubuntu 12.04.