Arm*_*lam 1 command-line bash history bash-history
如何在没有行号的情况下获取 Ubuntu 终端历史记录?
history
Run Code Online (Sandbox Code Playgroud)
history命令返回带有行号的先前命令。我正在寻找类似的东西:
cd tizen-sdk\tools
ls
Run Code Online (Sandbox Code Playgroud)
代替
924 cd tizen-sdk\tools
925 ls
Run Code Online (Sandbox Code Playgroud)
您可以改用该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)
Run Code Online (Sandbox Code Playgroud)
所以:
fc -ln
Run Code Online (Sandbox Code Playgroud)
您也可以直接查看历史文件,但它可能不会更新:
cat "$HISTFILE"
Run Code Online (Sandbox Code Playgroud)