请问在一个命令上加什么参数可以实现下面命令的内容在同一行输出。 echo "zhaokang";echo "zhaokang"
程序员文章站
2022-06-01 07:56:31
请问在一个命令上加什么参数可以实现下面命令的内容在同一行输出。 echo "zhaokang";echo "zhaokang" [root@zhaokang test]# echo "zhaokang";echo "zhaokang"zhaokangzhaokang 解答: [root@zhaoka ......
请问在一个命令上加什么参数可以实现下面命令的内容在同一行输出。 echo "zhaokang";echo "zhaokang"
[root@zhaokang test]# echo "zhaokang";echo "zhaokang"
zhaokang
zhaokang
解答:
[root@zhaokang test]# echo -n "zhaokang";echo "zhaokang"
zhaokangzhaokang
说明:此题考察echo的-n 参数。echo的命令经常用,需要总结如下:
echo
-n do not output the trailing newline
-e enable interpretation of backslash escapes
加-n 是取消换行符
加-e参数是可以使用转义字符
[root@zhaokang test]# echo -ne "zhaokang\t";echo "zhaokang"
zhaokang zhaokang
[root@zhaokang test]# echo -e "zhaokang\tguobaoyan"
zhaokang guobaoyan
[root@zhaokang test]# echo -e "zhaokang\nguobaoyan"
zhaokang
guobaoyan
上一篇: 这几位大汉是要弄啥