linux脚本编辑按上键出现A,[转] linux下shell中使用上下键翻出历史命名时出现^[[A^[[A^[[A^[[B^[[B的问题解决,Linux使用退格键时出现^H解决方法...
发布日期:2021-06-24 15:58:01 浏览次数:2 分类:技术文章

本文共 2275 字,大约阅读时间需要 7 分钟。

[From]

https://www.zmrbk.com/post-2030.html

https://blog.csdn.net/suifengshiyu/article/details/40952771

我的理解是,如果出现如题所描述的问题,这是因为使用了不同的shell程序和对应的stty设置对应关系所综合作用的结果。

这是/bin/sh里面stty -a命令输出的信息:

$ stty -a

speed38400 baud; rows 43; columns 209; line = 0;

intr= ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8

opost-olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0

isig icanon iextenecho echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

这是/bin/bash里面stty -a命令输出的信息,可以看到不同的字符映射:

pekkle@PPLinux:~$ stty -a

speed38400 baud; rows 43; columns 209; line = 0;

intr= ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8

opost-olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0

isig icanon iextenecho echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

转发以上两篇文章,都是解决方法。简单的方法是用/bin/bash代替/bin/sh,在ubuntu里是正常的。

linux下shell中使用上下键翻出历史命名时出现^[[A^[[A^[[A^[[B^[[B的问题解决

今天在使用kali linux的时候,使用上下键想翻出历史命令时,却出现^[[A^[[A^[[A^[[B^[[B这种东东,而tab键补全命令的功能也无法使用。

最终发现是由于当前用户使用的shell是/bin/sh的原因。

useradd的时候没有指定用户的shell类型,因此默认为/bin/sh。1:查看当前用户的shell类型命令: echo$SHELL2:改变当前用户登录默认的shell:chsh -s /bin/bash username 或者使用usermod -s /bin/bash username命令

默认的shell改成/bin/bash之后正常了。

bash和sh的区别:http://hi.baidu.com/aaronike/item/08cfca8ab2ca145d850fabd3

sh其实是dbash的软连接。

Linux使用退格键时出现^H解决方法

以前在linux下执行脚本不注意输错内容需要删除时总是出现^H ,以前不知道真相的我没办法只有再重头运行一次脚本,后来发现其实时有解决办法的,所以记录一下。^H不是H键的意思,是backspace。主要是当你的终端backspace有问题的时候才需要设置。

解决方法有两种:1、要使用回删键(backspace)时,同时按住ctrl键2、设定环境变量

在脚本的开头或结尾 参数 stty erase^H stty erase ^?在bash下:$ stty erase^?或者把 stty erase^?添加到.bash_profile中。

在csh下:$ stty erase^H

或者把 stty erase^H 添加到.cshrc中

转载地址:https://blog.csdn.net/weixin_33682804/article/details/116655959 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:观察内核linux行为,Linux内核|实验四 观察 Linux 行为
下一篇:linux 防火墙添加6309端口,关于在linux下部署垂直集群的问题

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月15日 15时06分05秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章