about history command
history is a usefull command for many purposes like “recall a command”, investigation…
This memo is about ‘history tips’ i find useful :
- add date and time :
export HISTTIMEFORMAT=”%F %T “ (or any strftime format, I prefer : %Y%m%d %F) - hide some commands, this may be usefull if you wanna type passwords (like FTP, mysql…) :
- export HISTCONTROL=ignorespace
- prefix commands you want to hide with a space
- ignore some commands that are not important (for you) :
export HISTIGNORE=”pwd:ls:cd:” - re-use a previous command argument :
Suppose that, before deleting a file, i prefer to check it with ls first…- ls -lh /path/to/the/file/i/want/to/check/myfile
- rm -f !ls:2
:2 refers to 2nd argument i passed to command ls found in history
credits go mainly to this site : http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/