Heim  >  Fragen und Antworten  >  Hauptteil

linux - shell下如何确定输入为backspace

看下面的代码

stty cbreak -echo  
input==`dd if=/dev/tty bs=1 count=1 2>/dev/null`  
stty -cbreak echo  
if [ "$input" = "a" ];then
    echo "输入的是a"
fi

我如何确定输入的是退格键(backspace)呢,也就是说backspace的标志是什么?

PHP中文网PHP中文网2720 Tage vor426

Antworte allen(1)Ich werde antworten

  • 迷茫

    迷茫2017-04-17 11:27:57

    if [ "$input" = $(echo -ne '\b') ];then
    

    Antwort
    0
  • StornierenAntwort