How to search eml file contents without opening?
How to search inside contents of eml files?
How to search inside contents of eml files?
To search for eml files in Linux is quite straight forward.
If the eml files is in a single folder searching will be
faster since it doesn't need to recursively search on other folders.
Grep command in Linux can do the task for searching contents
of eml files.
Since eml files are pure text file command below can also be used to search any text files.
Since eml files are pure text file command below can also be used to search any text files.
Here's the command:
grep -R -H -e "^Jun" *.eml > output.txt
There is no need to specify the path or directory if the command is executed on the directory where the eml or text files resides.
Output above returns only the first match that contains the
keyword and the filename.
If the eml files contains the match multiple times then the
filename will be listed repetitively.
Sort the output and only get unique values so result will not be convoluted if there are quite a few matches.
grep -R -H -e "^Jun" *.eml | sort | uniq > output.txt
Sample output:
00001473.eml:Jun,
00001473.eml:Jun
00001746.eml:Jun,
000017fa.eml:Jun
00001801.eml:Jun
00001801.eml:Jun
00001801.eml:Jun
00001801.eml:Jun
00001801.eml:Jun
00001801.eml:Jun
00001801.eml:Jun
000019b7.eml:Jun
000019b7.eml:Jun
00001a7f.eml:Jun
00001b29.eml:Jun
00001b29.eml:Jun
00001b2c.eml:Jun
00001b2d.eml:Jun
00001b2d.eml:Jun
00001b2f.eml:Jun
00001b33.eml:Jun
Another method is:
grep -r -H
"server" *.eml > output.txt
Output of the above command is quite heavy it will return
the paragraph or phrase that will match the keyword, the file name will also be
included since -H is one of the parameter.
Grep parameter used on the command:
-H, Print the
file name for each match.
-R, -r,
--recursive Read all files under each
directory, recursively.
-e Specify a regex pattern
Use "man grep" to explore other parameters.
To search for for a whole word or two keywords, type this command:
grep -H -R -w “server room” filex.eml > output.txt
It's just a simple and basic searching using grep. If you
want more powerful searching then a combination of sed and awk will be needed.
Above Grep command is quite useful it is like doing an injection search for all the files and returns the file name that matches the keyword. Very useful on searching large number of text or eml files.
Cheers..Hope it helps..
Comments
Post a Comment