-
#!/bin/sh echo "Num of arguments: $#" echo "Current PID: $$" echo "BASHPID: $BASHPID" sleep 10 & echo "The last deforegroud PID: $!" echo "The current shell options: $-"
-
shell中可以使用8进制转义序列
格式必须为$‘\octal‘
$号可以至于string前
$"string" & "string" 无任何区别
$‘string‘ & ‘string‘ 是有很大区别 ‘string‘ 原样输出, $‘string‘ 会让strin*生转义效果
必须将"$IFS"用 ""包裹,否则shell会把 空格 "\t" 去掉
xxd -b 二进制显示 xxd -u 大写hexdecimal显示 od -b octal od -c characters
-
颜色输出的函数
#!/bin/sh #==== Colorized variables ==== if [[ -t 1 ]];then # is terminal BOLD="\e[1m"; DIM="\e[2m"; RED="\e[0;31m"; RED_BOLD="\e[1;31m"; YELLOW="\e[0;33m"; YELLOW_BOLD="\e[1;33m"; GREEN="\e[0;32m"; GREEN_BOLD="\e[1;32m"; BLUE="\e[0;34m"; BLUE_BOLD="\e[1;34m"; GREY="\e[37m"; CYAN_BOLD="\e[1;36m"; RESET="\e[0m"; fi function log() { echo -e "${GREY}# ${@}${RESET}"; } function title() { echo -e "${BLUE_BOLD}# ${*}${RESET}"; } function finish() { echo -e "\n${GREEN_BOLD}# Finish!${RESET}"; exit 0; } function userAbort() { echo -e "\n${YELLOW_BOLD} Abort! ${RESET}"; exit 0; } function success() { echo -e "${GREEN} Success: ${@} ${RESET}"; } function warn() { echo -e "${YELLOW_BOLD} Warning: ${*} ${RESET}"; } function error() { echo -e "${RED_BOLD} Error: ${RED}${@}${RESET}\n"; exit 1; } log uoiop bnm title uiop zxc success uioppp vbnm warn uioppp vbn userAbort "uoop" error ‘parameter error‘
-