发现文件编码的差异

我正在使用msmtp从cmd发送电子邮件

cat > test1 << EOF >From: "Tester" >test >EOF cat test1 | msmtp [email protected] 

这工作时:

 echo -e 'From: "Tester"\ntest' > test2 cat test2 | msmtp [email protected] 

虽然不起作用

 diff test1 test2 

什么也没有返回

  file -bi test1 test2 

返回了相同的结果

  message/rfc822; charset=us-ascii 

问题是你没有使用echo命令的-e选项。

尝试这个:

 echo -e 'From: "Tester"\ntest' > test2 cat test2 | msmtp [email protected] 

-e用于告诉回显来解释转义字符(如“\ n”)。