shell脚本攻略读书笔记之一

Shell脚本攻略读书笔记之一

[root@server5 local]# echo "hello shell"
hello shell
[root@server5 local]# printf "hello shell"
hello shell[root@server5 local]# # printf "hello shell\n"
hello shell
[root@server5 local]# 


(1)(-表示左对齐,没有则表示右对齐)
(2)赋值语句的等号左右切记不要有空格!
(3)第一个echo hello会被视作一个命令,第二个hello会被单独视为一个命令!
[root@server5 local]# echo hello;hello
hello
-bash: hello: 未找到命令
(4)bash不会对单引号中的变量(如$var)求值,而只是照原样输出。

(5)while using flags for echo and printf, alwanys make sure that the flags appear before any strings in the command,otherwise Bash will consider the flags as another string.
What's meaning of "flags?"

(6)[root@server5 local]# echo -e "\e[1;31m this is red txt \e[0m"
 this is red txt 
\e[1;31m is the escape string that sets the color to red
\e[0m resets the color back.

猜你喜欢

转载自blog.csdn.net/liu16659/article/details/81066073