echo 在命令中不起作用
我运行以下命令进行日志监控。
echo ---------------------BEGIN:0;awk ' NR == NR {print $0; recno=NR; rec=$0} END {printf "output is %010d>%s",recno, rec} ' "/var/log/messages";echo ;echo ------------------END:0;
预期的输出是
Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!
output is 0000028518>Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!
---------------------END:0
但是在一个 AIX 5.3 机器(ksh)上我得到以下输出
Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!
output is 0000028518>Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!---------------------END:0
在“Aborting!”之后没有“新行”由于倒数第二个 echo 命令,它应该在那里。
这种情况只发生在那个特定的盒子上。 有人能告诉我为什么会这样吗?
I run following command for log monitoring.
echo ---------------------BEGIN:0;awk ' NR == NR {print $0; recno=NR; rec=$0} END {printf "output is %010d>%s",recno, rec} ' "/var/log/messages";echo ;echo ------------------END:0;
The expected output is
Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!
output is 0000028518>Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!
---------------------END:0
But on one AIX 5.3 box(ksh) I get following output
Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!
output is 0000028518>Nov 12 03:36:52 hostname gdm[27726]: GDM already running. Aborting!---------------------END:0
There is no "new line" after "Aborting!" which should be there because of second last echo command.
This happens only on that particular box.
Can anybody please tell me why this is so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
某些版本的 Unix 有一个 echo,如果没有参数,则不会输出任何内容,甚至不会输出换行符。可能 AIX 就是其中之一(我从未使用过,所以不知道)。这样做:
这告诉 echo 输出一个空字符串,后跟一个换行符。
Some versions of Unix have an echo that outputs nothing, not even a newline, if it has no arguments. Might be AIX is one of these (I have never used so don't know). Do this instead:
This tells echo to output an empty string, followed by a newline.