In this article I would take about Bash history commands and how to efficiently use them. I won't do much apart from providing some good links in this regard:
Summary of some commands:
- Bash History
- !! - repeat last command
- !foo - repeat last command starting with 'foo'
- CTRL + R - command auto completion
- history - prints a numbered list of previously typed commands
- !N - executes Nth command in the history list
- !foo:p - prints a command without executing it
- !$ - last argument (word) of the previous command
- !* - all arguments of previous commands
- ^error^correction - re-executes previous command by replacing 'error' with 'correction'
- Home / END
- CTRL + a - beginning of a line
- CTRL + e - End of a line
- CTRL + w - erase a word
- CTRL + u - erase from here to the beginning of the line
- Modifying History behaviour
$ export HISTFILESIZE=500
$ export HISTIGNORE="&:[ ]*:exit"
This ignores repeated commands, commands that start with a space and 'exit' and they are not added to bash history
$ shopt -s histappend
$ shopt -s histverify
allows users to verify a substituted history expansion.
$ shopt -s histreedit
allows users to re-edit a failed history substitution
Put these lines into .bashrc file so that you won't have to type them again and again
No comments:
Post a Comment