Ubuntu – View terminal history without the line number

bashbash-historycommand linehistory

How can I get the Ubuntu terminal history without the line number?

history

history command returns the previous commands with line number. I am looking for something like:

 cd tizen-sdk\tools          
 ls

instead of

924  cd tizen-sdk\tools      
925  ls

Best Answer

You can use the fc command instead. From 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)

Therefore:

fc -ln

You can also look at the history file directly, but it might not be updated:

cat "$HISTFILE"
Related Question