如何通过管道将 mailx 标头传输到外部文件。总是被截断
如果邮件的主题稍长,则不可能将其通过管道传输到任何命令或外部文件而不被截断。为什么?以及如何正确地做到这一点?
示例:
mail -H -f mbox
显示多封邮件。一切看起来都不错。
O 3 [电子邮件受保护] 5 月 31 日星期二 13:39 22 /596 这是一个很长很长的主题
,但是一旦有人尝试用管道做任何事情,它就会中断
mail -H -f mbox | tee
O 3 [email protected] Tue May 31 13:39 22/596 This is a ver
它只会连续显示 78 个字符,仅此而已。
如果我这样做也是一样
mail -H -f mbox >> into_a_file
mail -H -f mbox | grep -----
mail -f mbox | less
并且它在 xterm、gnome-terminal 等中不起作用... 无论我设置 COLUMNS 还是 TERMWIDTH(在 mailx 之外或使用 -S 选项...)
为什么会这样?
if the subject of a mail is a little longer then it is not possible to pipe it to any command or external file without getting truncated. Why? And how do you do it correctly?
Example:
mail -H -f mbox
shows several mails. Everything looks OK.
O 3 [email protected] Tue May 31 13:39 22/596 This is a very long long long Subject
But as soon as one tries to do ANYTHING with a pipe it will break
mail -H -f mbox | tee
O 3 [email protected] Tue May 31 13:39 22/596 This is a ver
It will only display 78 characters in a row and nothing more.
The same if I do
mail -H -f mbox >> into_a_file
mail -H -f mbox | grep -----
mail -f mbox | less
And it is not working in xterm, in gnome-terminal etc...
No matter if I set the COLUMNS or the TERMWIDTH (outside of mailx or with the -S option...)
Why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,mailx 在提供输出和重定向输出方面的行为有所不同。
阅读手册表明,消息头的标准输出可以使用
这相当于以特定格式给出输出(如 C 中的 printf),
看起来在管道输出时,%S 字段被截断。要保留主题标头,请将 %S 更改为 %150S(字段宽度 150)之类的内容。
From what I can see, mailx is behaving differently in giving output versus redirecting it.
Reading the manual shows that the standard output of message headers is possible with
This is the equivalent of giving output with a specific format (like printf in C)
Looks like this is getting truncated for the %S field when piping the output. To preserve the subject header, change the %S to something like %150S (field width 150).