I want to find all emails in my IMAP folders that contain a certain text (namely: that are sent to a certain email address). I already found out I can do so by using grep like so:
grep -rnw '~/users/example' -e "email@example.com"
This returns either the matched text or the name of the file (with
-l). But what I really need for my task is to know the "Title" of the email file that was found.
/home/example/users/example/.Archives.2013/cur/1364614080.4080.example.com:2,Sa /home/example/users/example/.Archives.2013/cur/1385591317.91317.example.com:2,RSa /home/example/users/example/.Archives.2013/cur/1358235054.35054.example.com:2,S /home/example/users/example/.Archives.2013/cur/1358445545.45545.example.com:2,S /home/example/users/example/.Archives.2013/cur/1453119248.M330746P8611.example.com,S=6761,W=6915:2,S
So, I somehow need to find the files based on the grep above, but the result that is listed should be a different part of that same file (maybe with regex?).
How can I go about this?