1. Path Name Expansion
{pattern1,pattern2,..}
注意不能有空格。
e.g.
root@localhost :~# echo file{1,2,3,5{6,7.8}}.txt
file1.txt file2.txt file3.txt file56.txt file57.8.txtshell
2. 设置终端输出的颜色
root@test-desktop:/home/James# echo -e "\033[32;40;5;1m ok \033[0m"
ok express
3. test command
condition: an expression that evaluates to a boolean value
test condition && true-command || false-command
test condition && true-command
test condition && false-command
(注意,若是要比较数字大小,不能用> <,由于在shell中,他们的语义是重定向!要用-gt或者-lt)
e.g.
root@localhost :~# test 1 -le 2 && echo Yes || echo No
Yes
root@localhost :~# test 1 -gt 2 && echo Yes || echo No
No
root@localhost :~# test 5 = 5 && echo Yes || echo No
Yes
root@localhost :~# test 5 = 15 && echo Yes || echo No
No
root@localhost :~# test 5 != 5 && echo Yes || echo No
Nolua
4. if statements
if test condition; then
command1
command2
....net
fi命令行
if [ condition ]; then
command1
command2
....
figet
5. conditional execution
command1 && command-success
command1 || command-fail
command1 && command-success || command-failit
[ condition ] && true-command
[ condition ] || false-commandio
6. 命令行参数(command line parameters)
也叫作位置参数(positional parameters),由于咱们用$1 $2等来访问他们。
$# -- 参数个数
$@ -- 等价于"$1" "$2" ... "$n"
$* -- 等价于"$1y$2y...y$n",其中y是$IFS,这暗示了若是咱们改变IFS,能够改变$*的输出形式,好比IFS=","。test
7. case statement
case $var-name in
pattern1|pattern2)
command1
...
commandn
;;
pattern3|pattern4)
command1
...
commandn
;;
*)
command
;;
esacfile