echo
echo -e 會打印換行等轉(zhuǎn)義符號
echo "$PATH" 雙引號內(nèi)的變量會自動解析,不需要拼接
read
read -p "提示信息" loginuser
-r "支持轉(zhuǎn)義信息讀取"
-t 指定多長時間超時
# 如果 loginuser 為空,默認(rèn)值為admin
if [ -z "${loginuser}" ];then
loginuser=admin
fi
在read語句之前添加 stty erase '^H'
此時用退格鍵就沒問題了
pgrep
直接查看命令的進(jìn)程號 pgrep adminservice
取代 ps aux | grep adminservice | grep -v grep | awk -F ' ' '{print $2}'
if
if cmd;then
# 如果cmd執(zhí)行成功,那么執(zhí)行該分支
fi
if ! cmd; then
# 如果cmd執(zhí)行失敗,那么走該分支
fi
cd /var/www/xxx || exit # 如果打開目錄失敗,那么退出
for
for i in aaa bbb ccc ddd;do
echo $i
done
ip=($(/sbin/ip a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk -F ' ' '{print $2}'))
for i in $(seq ${#ip[@]});do
tmp=$(echo "${ip[i-1]}" | sed 's/\/[[:alnum:]]\{2\}//')
echo " 網(wǎng)卡編號: $i. $tmp"
done
ss
查看系統(tǒng)socket 統(tǒng)計(jì)信息
ss -s
Total: 2148
TCP: 271 (estab 35, closed 214, orphaned 1, timewait 206)
Transport Total IP IPv6
RAW 2 0 2
UDP 32 25 7
TCP 57 44 13
INET 91 69 22
FRAG 0 0 0
查看當(dāng)前進(jìn)程的文件打開數(shù):lsof -p 2324 | wc –l
查看當(dāng)前端口的文件打開數(shù):lsof -i:80 | wc -l
查看當(dāng)前所有進(jìn)程文件打開數(shù):lsof | wc -l
sed 替換
sed -i "1,2s/dest/replace/" file # 替換第1到2行的dest為replace
axel
axel --help
Usage: axel [options] url1 [url2] [url...]
--max-speed=x -s x Specify maximum speed (bytes per second)
--num-connections=x -n x Specify maximum number of connections
--max-redirect=x Specify maximum number of redirections
--output=f -o f Specify local output file
--search[=n] -S[n] Search for mirrors and download from n servers
--ipv4 -4 Use the IPv4 protocol
--ipv6 -6 Use the IPv6 protocol
--header=x -H x Add HTTP header string
--user-agent=x -U x Set user agent
--no-proxy -N Just don't use any proxy server
--insecure -k Don't verify the SSL certificate
--no-clobber -c Skip download if file already exists
--quiet -q Leave stdout alone
--verbose -v More status information
--alternate -a Alternate progress indicator
--help -h This information
--timeout=x -T x Set I/O and connection timeout
--version -V Version information
eg:
axel -n 10 https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2207-02.iso\?spm\=a2c6h.25603864.0.0.34ea6aeaDqg255