开发者社区> 问答> 正文

Linux基本命令中 history命令如何从命令历史中剔除连续重复的条目?

已解决

Linux基本命令中 history命令如何从命令历史中剔除连续重复的条目?

展开
收起
去校区学技术 2022-04-02 14:32:05 692 0
1 条回答
写回答
取消 提交回答
  • 推荐回答

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

    # 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
    
    
    2022-04-02 14:58:07
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Alibaba Cloud Linux 3 发布 立即下载
ECS系统指南之Linux系统诊断 立即下载
ECS运维指南 之 Linux系统诊断 立即下载