You could use sed
. Say:
history | sed -n '2960,2966p'
to print line numbers 2960 to 2966 from the output of history
command.
Quoting help history
:
If the $HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry. No time stamps are printed otherwise.
You could set the format to get the timestamp in the desired format by saying:
export HISTTIMEFORMAT="%F %T "
Since the history
file is written by default only upon session close, you'd need to say:
history -w
in order to update the history file in the current session.