echo命令结果和echo文本字符串在同一行显示,实现如下: 只需要加 -n 参数即可 [root@localhost ~]# cat 1.sh #!/bin/bash #This script displays the date and who's logged on echo The time and date are: date echo Let's see who's logged into the system: who ********************************************************* root@localhost ~]# ./1.sh The time and date are: 2014年 11月 06日 星期四 14:59:28 CST Lets see whos logged into the system: root pts/1 2014-11-06 09:03 (192.168.18.22) ************************************************************ [root@localhost ~]# cat 1.sh #!/bin/bash #This script displays the date and who's logged on echo -n The time and date are: date echo Let's see who's logged into the system: who ************************************************************** [root@localhost ~]# ./1.sh The time and date are:2014年 11月 06日 星期四 15:00:36 CST Lets see whos logged into the system: root pts/1 2014-11-06 09:03 (192.168.18.22)
转载于:https://blog.51cto.com/liangey/1573433
本文展示了如何使用echo命令结合-n参数在同一行显示Linux系统的当前时间和日期,以及当前登录的所有用户和详细信息。通过简单的脚本实例,用户可以轻松地获取系统实时状态。
541

被折叠的 条评论
为什么被折叠?



