日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux Shell学习(3)

發布時間:2025/6/15 linux 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux Shell学习(3) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

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.txt


2. 設置終端輸出的顏色
root@test-desktop:/home/James# echo -e "\033[32;40;5;1m ok \033[0m"
?ok


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
No

4. if statements
if test condition; then
?command1
?command2
?...

fi


if [ condition ]; then
?command1
?command2
?....
?
fi


5. conditional execution
command1 && command-success??
command1 || command-fail
command1 && command-success || command-fail

[ condition ] && true-command
[ condition ] || false-command


6. 命令行參數(command line parameters)
也叫做位置參數(positional parameters),因為我們用$1 $2等來訪問他們。
$# -- 參數個數
$@ -- 等價于"$1" "$2" ... "$n"
$* -- 等價于"$1y$2y...y$n",其中y是$IFS,這暗示了如果我們改變IFS,可以改變$*的輸出形式,比如IFS=","。


7. case statement
case $var-name in
?pattern1|pattern2)
??command1
??...
??commandn
??;;
?pattern3|pattern4)
??command1
??...
??commandn
??;;
?*)
??command
??;;
esac

?

?

?

?

轉載于:https://my.oschina.net/u/158589/blog/57071

總結

以上是生活随笔為你收集整理的Linux Shell学习(3)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。