linux 終端 backspace不能刪除字元

來源:互聯網
上載者:User

標籤:

http://blog.chinaunix.net/uid-2282111-id-2113293.html

在linux/unix平台的經常使用scanf從鍵盤擷取字元,輸出字元後按Backspace鍵刪除時,會出現^H,這對習慣了按Backspace鍵刪除的使用者來說,感覺非常彆扭,雖然可以通過Ctrl+Backspace按鍵組合實現刪除功能

可通過stty命令修改終端配置來實現Backspace刪除功能。如下:

QUOTE:   

[[email protected] ~]$ id

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),503(asadmin)

[[email protected] ~]$ stty erase ^h

若要恢複Ctrl+Backspace按鍵組合刪除功能,可執行以下命令:

QUOTE:

[[email protected] ~]$ id

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),503(asadmin)

[[email protected] ~]$ stty erase ^?

同時可通過stty -a查看所有的終端設定:

QUOTE:

oracle||oralinux||/home/oracle||-->>id
uid=500(oracle) gid=501(oinstall) groups=500(dba),501(oinstall)
oracle||oralinux||/home/oracle||-->>stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

 

linux 終端 backspace不能刪除字元

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.