History(历史)命令用法 - 使用 HISTCONTROL 从命令历史中剔除

使用 HISTCONTROL 从命令历史中剔除连续重复的条目

在下面的例子中,pwd 命令被连续执行了三次。执行 history 后你会看到三条重复的条目。要剔除这些重复的条目,你可以将 HISTCONTROL 设置为 ignoredups:[code]# pwd

pwd

pwd

history | tail -4

44 pwd
45 pwd
46 pwd [Note that there are three pwd commands in history, after executing pwd 3 times as shown above]
47 history | tail -4

export HISTCONTROL=ignoredups

pwd

pwd

pwd

history | tail -3

56 export HISTCONTROL=ignoredups
57 pwd [Note that there is only one pwd command in the history, even after executing pwd 3 times as shown above]
58 history | tail -4[/code]