HISTORY
名称
history 列出历史使用过的bash 命令
梗概
history [n]
history -c
history -d offset
history -anrw [filename]
history -p arg [arg ...]
history -s arg [arg ...]
描述
没有参数时,显示具有行号的历史命令的列表.
Lines listed with a * have been modified.
An argument of n lists only the last n lines.
If the shell variable HISTTIMEFORMAT is set and not null, it is used as a format string for strftime(3) to display the time stamp associated with each displayed history entry. No intervening blank is printed between the formatted time stamp and history line.
If filename is supplied, it is used as the name of the history file; if not the value of HISTFILE is used.
Options, if supplied, have the following meanings:
- -c Clear the history list by deleting all the entries.
- -d offset 删除第offset位置的历史
- -a 将目前新增的history指令新增入histfiles中,若没有加histfiles,则预设写入~/.bash_history
- -r: 将histfiles的内容读取到目前这个shell的history记忆中
- -w: 将目前的history记忆内容写入hisfiles
- -p 提取 args的历史将在标准输出上显示,不会把结果存储在历史列表中,每个arg必须要用引号包裹。
- -s 将args作为一个入口存储在历史列表中。在args被添加之前,历史列表中的上一条命令会被移除
如果HISTIMEFORMAT变量被设置,每条history入口相关的时间会以注释的形式写入history文件中。
当history文件被读取时,在history行前面的紧跟数字的注释会被看成时间。
返回值是0除非遇到了一个无效的参数,当读写history文件,一个无效的offset被提供给参数-d,或者history expansion supplied as an argument to -p fails.