关于linux命令脚本
Tofloor
poster avatar
SiyerBOBO
deepin
2019-02-18 01:23
Author
如题,我在/usr/bin下新建了一个文件

sudo vim cls

#! /bin/bash
#
printf "\033c"
history -c

保存退出

为什么每次我执行cls都会只清屏不清除历史输入啊。。?求教大佬
Reply Favorite View the author
All Replies
avatar
SiyerBOBO
deepin
2019-02-18 01:33
#1
难道要我在~/.bashrc 里alias cls = 'history -c'  ?那我printf "\033c"肿么办....
Reply View the author
avatar
funtoo
deepin
2019-02-18 03:54
#2
history -c清除的是内存中保留的当前交互式shell会话的命令历史,但是shell脚本执行过程会fork一个非交互式的shell会话,所以不会有用。
printf没有这个限制。
Reply View the author
avatar
SiyerBOBO
deepin
2019-02-18 03:58
#3
https://bbs.deepin.org/post/174810
history -c清除的是内存中保留的当前交互式shell会话的命令历史,但是shell脚本执行过程会fork一个非交互式 ...

谢谢~ 了解了
Reply View the author