Difference between revisions of "Bash history"

From wikieduonline
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:
  
 
== Usage ==
 
== Usage ==
* Basic example:
+
* Save every executed command to: <code>[[~/.bash_history]]</code>
:<code>[[export]] [[PROMPT_COMMAND]]='[[history --help|history -a]]'</code>
+
:<code>[[export]] [[PROMPT_COMMAND]]='[[history -a]]'</code>
 
* Advanced examples:  
 
* Advanced examples:  
 
** <code>echo '[[export]] [[HISTTIMEFORMAT]]="%d/%m/%y %T "' >> ~/.[[bash_profile]]</code><ref>https://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/</ref>
 
** <code>echo '[[export]] [[HISTTIMEFORMAT]]="%d/%m/%y %T "' >> ~/.[[bash_profile]]</code><ref>https://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/</ref>

Latest revision as of 14:33, 25 January 2024

Bash command history feature allows to recall, edit and rerun previous commands. Also allows commands to be saved using the history -a command[1][2].

Variables to control Bash History:

Usage[edit]

export PROMPT_COMMAND='history -a'

Activities[edit]

  1. Install https://github.com/ohmybash bash customization
  2. Review output from history command

Other terms[edit]

See also[edit]

Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.

Source: https://en.wikiversity.org/wiki/Bash_programming/Bash_History

Advertising: