• 基础命令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

  • 相关阅读:
    分享memcache和memcached安装过程(转)
    ios画图总结
    mac os下通过命令行的方式编译c++代码并在xcode里引用
    ubuntu访问windows共享文件夹
    为iphone 及iphone simulator编译boost库
    ubuntu 11.10 x64 安装oracle 11gR2时碰到的问题及解决方法
    模拟器与真机下ffmpeg的编译方法(总结版)
    ios 在View里绘图
    memcached1.4.4在ubuntu下编译的注意事项
    Google Code 服务试用
  • 原文地址:https://www.cnblogs.com/lfdblog/p/10659016.html
Copyright © 2020-2023  润新知