請問在一個命令上加什麼引數可以實現下面命令的內容在同一行輸出。 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 “;echo “zhaokang”
zhaokang zhaokang
[root@zhaokang test]# echo -e “zhaokang guobaoyan”
zhaokang guobaoyan
[root@zhaokang test]# echo -e “zhaokang
guobaoyan”
zhaokang
guobaoyan