精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學習啦 > 學習電腦 > 操作系統(tǒng) > Linux教程 > Linux中history命令怎么用(2)

      Linux中history命令怎么用(2)

      時間: 孫勝652 分享

      Linux中history命令怎么用

        9.使用 HISTCONTROL 清除整個命令歷史中的重復條目

        上例中的 ignoredups 只能剔除連續(xù)的重復條目。要清除整個命令歷史中的重復條目,可以將 HISTCONTROL 設置成 erasedups:

        代碼如下:

        # export HISTCONTROL=erasedups

        # pwd

        # service httpd stop

        # history | tail -3

        38 pwd

        39 service httpd stop

        40 history | tail -3

        # ls -ltr

        # service httpd stop

        # history | tail -6

        35 export HISTCONTROL=erasedups

        36 pwd

        37 history | tail -3

        38 ls -ltr

        39 service httpd stop

        [Note that the previous service httpd stop after pwd got erased]

        40 history | tail -6

        10.使用 HISTCONTROL 強制 history 不記住特定的命令

        將 HISTCONTROL 設置為 ignorespace,并在不想被記住的命令前面輸入一個空格:

        代碼如下:

        # export HISTCONTROL=ignorespace

        # ls -ltr

        # pwd

        # service httpd stop [Note that there is a space at the beginning of service, to ignore this command from history]

        # history | tail -3

        67 ls -ltr

        68 pwd

        69 history | tail -3

        11.使用 -c 選項清除所有的命令歷史

        如果你想清除所有的命令歷史,可以執(zhí)行:

        代碼如下:

        # history -c

        12.命令替換

        在下面的例子里,!!:$ 將為當前的命令獲得上一條命令的參數(shù):

        代碼如下:

        # ls anaconda-ks.cfg

        anaconda-ks.cfg

        # vi !!:$

        vi anaconda-ks.cfg

        補充:使用 !$ 可以達到同樣的效果,而且更簡單。

        下例中,!^ 從上一條命令獲得第一項參數(shù):

        代碼如下:

        # cp anaconda-ks.cfg anaconda-ks.cfg.bak

        anaconda-ks.cfg

        # vi -5 !^

        vi anaconda-ks.cfg

        13.為特定的命令替換指定的參數(shù)

        在下面的例子,!cp:2 從命令歷史中搜索以 cp 開頭的命令,并獲取它的第二項參數(shù):

        代碼如下:

        # cp ~/longname.txt /really/a/very/long/path/long-filename.txt

        # ls -l !cp:2

        ls -l /really/a/very/long/path/long-filename.txt

        下例里,!cp:$ 獲取 cp 命令的最后一項參數(shù):

        代碼如下:

        # ls -l !cp:$

        ls -l /really/a/very/long/path/long-filename.txt

        14.使用 HISTSIZE 禁用 history

        如果你想禁用 history,可以將 HISTSIZE 設置為 0:

        代碼如下:

        # export HISTSIZE=0

        # history

        # [Note that history did not display anything]

        15.使用 HISTIGNORE 忽略歷史中的特定命令

        下面的例子,將忽略 pwd、ls、ls -ltr 等命令:

        代碼如下:

        # export HISTIGNORE=”pwd:ls:ls -ltr:”

        # pwd

        # ls

        # ls -ltr

        # service httpd stop

        # history | tail -3

        79 export HISTIGNORE=”pwd:ls:ls -ltr:”

        80 service httpd stop

        81 history

        [Note that history did not record pwd, ls and ls -ltr]

        上面就是Linux下history命令的例子詳解了,從這15個例子中你能更深入的了解history命令的實際應用,如果你經常使用命令,相信history命令是你的好幫手。

      312236