Name

history

Synopsis

history [count]
history [options]

Print commands in the history list or manage the history file. With no options or arguments, display the history list with command numbers. With a count argument, print only that number of the most recent commands.

Options

-a

Append new history lines (those executed since the beginning of the session) to the history file.

-c

Clear the history list (remove all entries).

-d position

Delete the history item at position position.

-n

Read unread history lines from the history file into the history list.

-p argument ...

Perform history substitution on each argument, printing the results to standard output. The results are not saved in the history list. Each argument must be quoted.

-r

Read the history file and replace the history list with its contents.

-s argument ...

Store the arguments in the history list as a single entry.

-w

Write the current history list to the history file, overwriting the file.

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.