zl程序教程

您现在的位置是:首页 >  其他

当前栏目

shell脚本攻略读书笔记之一

shell 脚本 攻略 之一 读书笔记
2023-09-14 09:13:16 时间

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, always 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.