Linux系统history命令显示时间

[root@centos7 ~]#type history
history is a shell builtin
[root@centos7 ~]#help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
    Display or manipulate the history list.
    
    Display the history list with line numbers, prefixing each modified
    entry with a `*'.  An argument of N lists only the last N entries.
    
    Options:
      -c	clear the history list by deleting all of the entries
      -d offset	delete the history entry at offset OFFSET.
    
      -a	append history lines from this session to the history file
      -n	read all history lines not already read from the history file
      -r	read the history file and append the contents to the history
    	list
      -w	write the current history to the history file
    	and append them to the history list
    
      -p	perform history expansion on each ARG and display the result
    	without storing it in the history list
      -s	append the ARGs to the history list as a single entry
    
    If FILENAME is given, it is used as the history file.  Otherwise,
    if $HISTFILE has a value, that is used, else ~/.bash_history.
    
    If the $HISTTIMEFORMAT variable is set and not null, its value is used
    as a format string for strftime(3) to print the time stamp associated
    with each displayed history entry.  No time stamps are printed otherwise.
    
    Exit Status:
    Returns success unless an invalid option is given or an error occurs.

history为内部命令,使用”help history“查看帮助文档,其中“$HISTTIMEFORMAT”说明为显示格式的变量值。使用“man 3 strftime”查看具体设置详情。使用export命令设置为环境变量,最终实现为

[root@centos7 ~]#export HISTTIMEFORMAT="%F %T "

下次登录自动生效,写入当前用户的配置文件

[root@centos7 ~]#echo export HISTTIMEFORMAT="%F %T " >> .bash_profile
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值