SHELL
範例與常用技巧
檔頭常用宣告 # quickly syntax set -euo pipefail # let script exit if a command fails set -o errex...
grep
教學網站 http://www.cyberciti.biz/faq/grep-regular-expressions/ https://www.ubuntupit.com/practic...
test
字串或文字的比對 Str1 = str2 | 當str1與str2相同時, 傳回True Str1 != str2| 當str1與str2不同時, 傳回True Str1 < Str...
awk
教學網站 http://techarena51.com/index.php/advance-text-processing-examples-awk/ https://linuxhand...
sed
教學網站 http://www.tecmint.com/linux-sed-command-tips-tricks/ https://www.cyberciti.biz/faq/how-...
Auto-rar.sh
解壓縮多個分割檔案 (*.part0XX.rar) #!/bin/bash echo "-> Started: "`date +%m/%d/%y\ %H:%M\ %Z` echo...
Regex 正規表示式
教學網站 https://likegeeks.com/regex-tutorial-linux/ http://overapi.com/regex https://regexper.c...
管理與操作
查出目前使用哪種 SHELL ps -p $$ echo $0 echo $SHELL 執行 SHELL 的方式 sh file . file source file 常用鍵盤...
Function Samples
清理目錄裡的 *.gz 檔案 用法: KEEP=100 CleanUp /path/to/dir CleanUp() { dest="$1" if [ $dest ];t...
dialog
selection.sh #!/bin/bash # while-menu-dialog: a menu driven system information program DIA...
Array 陣列
陣列長度:${#str_list[@]} 陣列內容:${str_list[@]} #!/bin/bash str_list=("aaa" "bbb" "ccc" "ddd") e...
Learning SHELL
7 Bash tutorials to enhance your command line skills in 2021 Top 10 Free Resources to Learn Sh...
String Manipulation 字串處理
字串長度 my_string="abhishek" echo "length is ${#my_string}" Using expr str="my string" length=$...
loop
for loop for i in var1 var2 var3; do echo $i; done for ((i=1;i<=10;i++)); do echo $i; done ...
顯示進度 progress
範例:簡易版 echo -ne '>>> [20%]\r' # some task sleep 2 echo -ne '&g...
find
檔案大小 找出大於 1000 MB 的檔案 find / -type f -size +1000M 列出最大檔案的清單 find . -type f -exec wc -c {} \; ...