Grep all files in a directory and print matches with file name
Posted
by
javanix
on Super User
See other posts from Super User
or by javanix
Published on 2012-06-25T15:15:15Z
Indexed on
2012/06/25
15:18 UTC
Read the original article
Hit count: 255
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.
© Super User or respective owner