我有一个脚本,该脚本从邮箱中读取并处理在主题行中包含特定文本的邮件。当前mailx会获取与搜索字符串匹配的最新项,但是有没有办法让mailx来获取第一项?
例如:
$ mailx
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/oracle": 3 messages
> 1 Doe, John Fri May 24 14:56 260/12654 "RE: Test mail"
2 Doe, John Fri May 24 15:00 287/13577 "RE: Test mail"
3 Doe, John Fri May 24 15:35 341/15417 "RE: Test mail"
$ echo "(subject Test)" | mailx > testMail.txt
$ cat testMail.txt
"/var/spool/mail/oracle": 3 messages
> 1 Doe, John Fri May 24 14:56 260/12654 "RE: Test mail"
2 Doe, John Fri May 24 15:00 287/13577 "RE: Test mail"
3 Doe, John Fri May 24 15:35 341/15417 "RE: Test mail"
Message 3:
From john.doe@mail.com Fri May 24 15:35:25 2019
...
testMail.txt
将包含3号电子邮件的内容,但我希望能够在列表中以1号电子邮件开头。