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