查看不带行号的终端历史记录

查看不带行号的终端历史记录

如何在没有电话号码

history

history命令返回带有行号的先前命令。我正在寻找类似的东西:

 cd tizen-sdk\tools          
 ls

代替

924  cd tizen-sdk\tools      
925  ls

答案1

您可以改用该fc命令。来自help fc

fc: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]
    Display or execute commands from the history list.

    fc is used to list or edit and re-execute commands from the history list.
    FIRST and LAST can be numbers specifying the range, or FIRST can be a
    string, which means the most recent command beginning with that
    string.

    Options:
      -e ENAME  select which editor to use.  Default is FCEDIT, then EDITOR,
            then vi
      -l    list lines instead of editing
      -n    omit line numbers when listing
      -r    reverse the order of the lines (newest listed first)

所以:

fc -ln

您也可以直接查看历史文件,但它可能不会更新:

cat "$HISTFILE"

答案2

使用此命令:

history | cut -c 8-

答案3

使用awk

history | awk '{$1=""; print}'

相关内容