如何在shell脚本里开启history命令。

1.linux bash内置命令与普通命令的区别:which查不到的都是bash内置命令

 

2.history是bash内置命令,能不能开启由bash说了算

 

3.set -o查看是否开启

1)在交互式查看

[root@py-centos7 ~]# set -o |grep history
history on

2)在脚本里查看

[root@py-centos7 ~]# sh a.sh
history off

脚本内容:

##! /bin/sh
HISTFILE=~/.bash_history
set -o |grep history

 

4.set -o 命令 打开bash的history配置

脚本内容

##! /bin/sh
HISTFILE=~/.bash_history
set -o history
history

执行结果 :

 

posted @ 2018-03-28 17:12  tpchen  阅读(6370)  评论(0编辑  收藏  举报