Linux命令 history

history

歷史查詢命令,能夠看到以前的執行操做。存儲的數量能夠由環境變量HISTSIZE控制。docker

選項:shell

  n  history 30  顯示最近輸入的30條命令bash

  - c : 將當前shell中的全部history信息都刪除。spa

  - r : 將histfiles中的內容添加到 shell 的 history 中code

  -w : 將目前的history 內容添加到 histfiles中blog

  -a : 將目前新增的history加入histfiles中,若沒有加histfiles則加入到~/.bash_historyclass

 

幾個實用操做test

[root@iZj6c1fa4tkhgpvnd9f12rZ ~]# history 10
  320  echo $$
  321  echo $?
  322  history
  323  ss
  324  alias dir="ls -l"
  325  dir .
  326  unalias dir
  327  dir .
  328  history 30
  329  history 10

  第一列是命令的編號 應該說是第幾個吧, 變量

[root@iZj6c1fa4tkhgpvnd9f12rZ ~]# !325
dir .
demo_test  docker_demo	gpu_env  nvidia  Python-3.6.8.tgz

  這樣就是執行編號爲325的命令file

[root@iZj6c1fa4tkhgpvnd9f12rZ ~]# ls
demo_test  docker_demo  gpu_env  nvidia  Python-3.6.8.tgz
[root@iZj6c1fa4tkhgpvnd9f12rZ ~]# !!
ls
demo_test  docker_demo  gpu_env  nvidia  Python-3.6.8.tgz

  執行剛剛執行過的命令

 

!num -----執行第幾條歷史命令
!!     ------執行上一條命令
相關文章
相關標籤/搜索