SHELL
範例與常用技巧
檔頭常用宣告 Use Bash Strict Mode # quickly syntax set -euo pipefail # let script exit if a c...
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 < Str2 ...
awk
教學網站 https://linuxhandbook.com/awk-command-tutorial/ Running Awk in parallel to process 256M ...
sed
教學網站 http://www.tecmint.com/linux-sed-command-tips-tricks/ https://www.cyberciti.biz/faq/how-...
Sample Scripts
線上範例 ip.sh - 主機 Public IP 品質健檢 whoamifuck.sh - Linux 系統安全檢測 Auto-rar.sh 解壓縮多個分割檔案 (*.part...
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 陣列
Learning Bash Scripting – Indexed Array Explained With Examples Bash Scripting – Associative ...
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 for...
顯示進度 progress
範例:簡易版 echo -ne '>>> [20%]\r' # some task sleep 2 echo -ne '&g...
find
檔案名稱 # Find all *.bak files in the current directory and removes them with confirmation find . ...
uniq
uniq 與 sort 一起使用時,可以控制那些重複的資訊。 基本操作 $ cat file2 ChhatrapatiShahuMaharaj Dr.B.R.Ambedkar Budh...
date
Shell 範例 # Sample today=$(date +%Y/%m/%d) NOW=`date "+%Y/%m/%d %H:%M:%S"` eval `date "+day=...
Parallel and Multi-thread
GNU Parallel Official: https://www.gnu.org/software/parallel/ Download: http://ftp.gnu.org/gnu/p...
Installation sudo apt install mailutils # [On Debian, Ubuntu and Mint] sudo yum install ...
Perl
Tutorials Useful One-Line Scripts for Perl Useful One-Line Scripts for Perl (簡中)
lsof
Network Port What process is using the port 50000 lsof -i :50000 lsof -i :https lsof -i t...
算術
let #!/usr/bin/env bash let NUMBER1=10 let NUMBER2=3 # Addition => + operator let ADD=$N...
Diagrams
Linux Shell Lifecycle
ANSI Color
高亮文字 highlight() { mode=$1 string="$2" case "$mode" in red) echo ...
Cheat Sheets
PDF bash_cheat_sheet.pdf bash-shell-scripting.pdf Bash Parameter Bash Loops Bash Bas...