請問在一個命令上加什麼參數可以實現下麵命令的內容在同一行輸出。 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