Difference between revisions of "Tools/bash"
< Tools
Mario Manno (talk | contribs) |
m (Reverted edits by Oxudocopaj (talk) to last revision by Mario Manno) |
(One intermediate revision by one other user not shown) | |
(No difference)
|
Latest revision as of 17:36, 24 November 2010
Using the BASH History
You can see the history by executing
history
Add a command to the end of the history like this without executing it
history -s ls -la
Examples
!!:p # print last command !-2:$:p # print last word of second last command !ls:1:p # print first parameter of most recent command starting with ls !?perl?^:p # print first argument of most recent command line containing 'perl' !!:gs/la/lha/ # substitute all 'la' by 'lha' !!:gs/la/lha/:p # substitute all 'la' by 'lha' and print resulting command
Tuning with shopt
Change the behaviour of your bash with shopt
shopt -s histreedit # re-edit a failed history substitution shopt -s cdspell # correct minor spelling errors on cd shopt -s nocaseglob # case insensitive globbing (i.e. ls *.pdf) shopt -s hostcomplete # complete hostname if word contains @
Using set
set -b # report job status immediately
Misc
export GLOBIGNORE=".svn:.cvs" # glob ignore export FIGNORE=".svn:.cvs" # pathname completion ignore
fc -l # list history fc 3 5 # fix command 3 to 5 and execute them alias r='fc -s' # re-execute last command r ls # re-execute last command starting with ls r la=lh ls