首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >查看没有行号的终端历史记录

查看没有行号的终端历史记录
EN

Ask Ubuntu用户
提问于 2016-10-20 13:24:16
回答 3查看 1.3K关注 0票数 1

如果没有线路号码,我如何获得Ubuntu终端历史记录?

代码语言:javascript
复制
history

history命令以行号返回前面的命令。我在找这样的东西:

代码语言:javascript
复制
 cd tizen-sdk\tools          
 ls

而不是

代码语言:javascript
复制
924  cd tizen-sdk\tools      
925  ls
EN

回答 3

Ask Ubuntu用户

回答已采纳

发布于 2016-10-20 13:35:58

您可以使用fc命令代替。来自help fc

代码语言:javascript
复制
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)

因此:

代码语言:javascript
复制
fc -ln

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

代码语言:javascript
复制
cat "$HISTFILE"
票数 6
EN

Ask Ubuntu用户

发布于 2016-10-20 13:36:53

使用以下命令:

代码语言:javascript
复制
history | cut -c 8-
票数 2
EN

Ask Ubuntu用户

发布于 2016-10-20 13:50:01

使用awk

代码语言:javascript
复制
history | awk '{$1=""; print}'
票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/839639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档