Linux shell脚本按住任意键继续操作

                         Linux shell脚本按住任意键继续操作

#!/bin/bash

echo " 开始执行操作. ... "
get_char()
{
    SAVEDSTTY=`stty -g`
    stty -echo
    stty cbreak
    dd if=/dev/tty bs=1 count=1 2> /dev/null
    stty -raw
    stty echo
    stty $SAVEDSTTY
}

echo "Press any key to continue 。。。"
echo " CTRL+C break command bash ..." # 组合键 CTRL+C 终止命令!
char=`get_char`
echo " 操作完成 .... "

引用自:https://www.linuxidc.com/Linux/2013-03/81387.htm

猜你喜欢

转载自blog.csdn.net/HaHa_Sir/article/details/82865199