dominic bu gisti düzenledi . Düzenlemeye git
1 file changed, 23 insertions
file_email.sh(dosya oluşturuldu)
@@ -0,0 +1,23 @@ | |||
1 | + | #!/usr/bin/env bash | |
2 | + | # Save piped email to "$1/YYMMDD SUBJECT.eml" | |
3 | + | # | |
4 | + | # Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com> | |
5 | + | ||
6 | + | # Don't overwrite existing file | |
7 | + | set -o noclobber | |
8 | + | ||
9 | + | message=$(cat) | |
10 | + | ||
11 | + | mail_date=$(<<<"$message" ggrep -oPm 1 '^Date: ?\K.*') | |
12 | + | formatted_date=$(date -f "$mail_date" +%y%m%d) | |
13 | + | # Get the first line of the subject, and change / to ∕ so it's not a subdirectory | |
14 | + | subject=$(<<<"$message" ggrep -oPm 1 '^Subject: ?\K.*' | sed 's,/,∕,g') | |
15 | + | ||
16 | + | if [[ $formatted_date == '' ]]; then | |
17 | + | echo Error: no date parsed | |
18 | + | exit 1 | |
19 | + | elif [[ $subject == '' ]]; then | |
20 | + | echo Warning: no subject found | |
21 | + | fi | |
22 | + | ||
23 | + | echo "${message}" > "$1/$formatted_date $subject.eml" && echo Email saved to "$1/$formatted_date $subject.eml" |
Daha yeni
Daha eski