Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash, obtain email body from a text file including the email

Tags:

bash

unix

email

I have multiple files in a folder and each of them have one email message. Each message has a header in the format

Subject: formatting fonts 
To: [email protected] 
From: sender 

email body

How can I get the body? I can get the subject , to ,from by something like "read XX".. Since there's no tag like "Body:" I cant get the email body for now

Any help will be appreciated.

like image 479
Wenhao Cen Avatar asked Dec 27 '22 18:12

Wenhao Cen


1 Answers

You want everything but the first paragraph. sed can do this:

sed '1,/^$/d' file.txt

What it says is -- start at the beginning, (1) go to the first line that's blank (^$ -- has nothing between the beginning ^ and end $) and delete it (d).

like image 94
Grisha Levit Avatar answered Jan 20 '23 13:01

Grisha Levit