zoukankan      html  css  js  c++  java
  • linux bash基础特性

    使用history命令,取得命令历史,当bash进程结束后,会把命令历史存放到文件中,下次开机还能看到命令历史。

    • 定制history:通过设置环境变量,来定制history

      • 环境变量$HISTSIZE:默认值是1000,也就是最多存1000条命令。

      • 环境变量$HISTFILE:默认值是/home/登录用户/.bash_history。root用户是/root/.bash_history。bash进程退出后,把内存里的命令历史存放到此文件中。

      • 环境变量$HISTFILESIZE:默认值是1000。命令历史文件的大小。

      • 环境变量$HISTCONTROL:默认值是ignoredups。忽略重复的命令。

        • ignorespace:忽略以空格开头的命令。当不想让命令记录到history中时,使用此技巧。
        • ignoreboth:忽略以空格开头的命令,忽略重复的命令。
      • 修改环境变量的方法

        $ HISTCONTROL=ignoreboth
        
    • 语法:history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]

      • -c:清空全部历史
      • -d offset:删除指定位置的历史
      • -a:只把在这个会话里用过的命令,追加保存到文件$HISTFILE中
      • -r:加载文件$HISTFILE里的内容到history list内存中。
      • -w:把history list内存中的所有命令,都追加到文件$HISTFILE中
      • n:显示最后n条命令历史。
    • 调用历史命令!

      • !n:执行指定n处的命令
      • !!:执行上一次命令
      • !STRING:执行最近一个以STRING开头的命令。
    • 获得上一次命令里的最后一个参数

      • Esc .

      • Alt .

      • !$

        # ls /etc/systemd/system/sysinit.target.wants/
        dmraid-activation.service  lvm2-monitor.service      rhel-import-state.service
        iscsi.service              multipathd.service        rhel-loadmodules.service
        lvm2-lvmetad.socket        rhel-autorelabel.service
        lvm2-lvmpolld.socket       rhel-domainname.service
        # cd !$
        cd /etc/systemd/system/sysinit.target.wants/
        

    c/c++ 学习互助QQ群:877684253

    本人微信:xiaoshitou5854

  • 相关阅读:
    【转载】Nginx负载均衡之后碰到的问题
    【转载】Nginx
    【转载】大型网站架构系列之一,前言,不得不考虑的问题
    【转载】Windows上搭个Nginx集群环境玩玩
    [转载]反射
    【转载】Nginx 简介
    【转载】系统性能调优吐血总结分享
    【转载】nginx for windows: 让nginx以服务的方式运行
    poj2377
    poj2371
  • 原文地址:https://www.cnblogs.com/xiaoshiwang/p/12041829.html
Copyright © 2011-2022 走看看