Tools/bash

From C4 Wiki
< Tools
Revision as of 02:17, 24 November 2010 by Oxudocopaj (talk | contribs)
Jump to: navigation, search


Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page


CLICK HERE


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