zoukankan      html  css  js  c++  java
  • 基础命令history

    history   记录历史命令

       环境变量:

        HISTSIZE: 命令历史记录的条数;

        HISTFILE:  命令历史记录的文件,~/.bash_history;

        HISTFILESIZE: 命令历史文件记录历史的条数;

      常用参数:

        删除一条历史记录:   history -d OFFSET

    [root@web1 ~]# history  5
      999  ssh mysql1
     1000  history 
     1001  history  10
     1002  history 
     1003  history  5
    [root@web1 ~]# history  -d 1001
    [root@web1 ~]# history  5
     1000  history 
     1001  history 
     1002  history  5
     1003  history  -d 1001
     1004  history  5

        清空所有历史记录: history -c 

    [root@web1 ~]# history -c 
    [root@web1 ~]# history 
        6  history 

        显示历史中最近的#条命令;history #

    [root@web1 ~]# history  5
      999  ssh mysql1
     1000  history 
     1001  history  10
     1002  history 
     1003  history  5

        手动追加当前会话缓冲区的命令历史致历史文件中: history -a

    [root@web1 ~]# history  5
     1010  more  /root/.bash_history 
     1011  history 
     1012  sadfdasf
     1013  history 
     1014  history  5
    [root@web1 ~]# tail -n 5 ~/.bash_history 
    vim test.sh
    sh test.sh 
    mysql_config 
    cat /etc/hosts
    ssh mysql1
    [root@web1 ~]# history -a
    [root@web1 ~]# tail -n 5 ~/.bash_history 
    sadfdasf
    history 
    history  5
    tail -n 5 ~/.bash_history 
    history -a
    [root@web1 ~]# 

        调用历史中的命令: 

          !#

          !!: 上一个命令

          !string

          !$:调用上一条命令的最后一个参数

        控制命令历史的记录方式: 修改环境变量

          环境变量:HISTCONTROL

            ignoredups 忽略连续且重复的命令;    

            ignorespace 忽略所有以空白开头的命令;

            ignoreboth:ignoredups,ignorespace

  • 相关阅读:
    调用组件的C++代码
    如何用C语言读写文件
    linux 常用命令总结(tsg)
    com.mysql.jdbc.MysqlDataTruncation: Data trunca...
    SpringMVC配置
    中文转换成Unicode编码 和 Unicode编码转换为中文
    在visual studio中运行C++心得
    博客园博客转至个人网站博客声明
    Seafile安装踩坑
    不要因为走得太远,而忘了自己的初心
  • 原文地址:https://www.cnblogs.com/lfdblog/p/10659016.html
Copyright © 2011-2022 走看看