History
Configuration
We can add the date each command was run to the bash history
$HOME/.bashrc:
--------------
...
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# write stamp information associated with each history entry <---
HISTTIMEFORMAT="%d/%m/%y %T " <---
...
_$: cd
_$: source .bashrc
_$: history
...
2001 24/04/14 17:01:06 vi .bashrc
2002 24/04/14 17:01:22 source .bashrc
2003 24/04/14 17:01:25 history
Command line history ordered by date
a) awk + sed
_$: history | awk '{$1=""; print}' | sed 's/^[ \t]*//' | sort -t " " -n -k1.7 -k1.5 -k1 -k2
b) sed + cut
_$: history | sed 's/^[ \t]*//' | cut -d" " -f3- | sort -n -k1.7 -k1.4 -k1 -k2