spinner() { local pid=$1 local delay=0.5 local spinstr='|/-\' while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} sleep $delay printf "\b\b\b\b\b\b" done printf " \b\b\b\b" } # 以下使用例 (wait_proccess.sh > /dev/null 2>&1) & spinner $!