Difference between revisions of "Tools/bash"

From C4 Wiki
Jump to: navigation, search
m (Reverted edits by Oxudocopaj (talk) to last revision by Mario Manno)
 
Line 1: Line 1:
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://ebytery.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
 
----
 
=[http://ebytery.co.cc CLICK HERE]=
 
----
 
</div>
 
 
=Using the BASH History=
 
=Using the BASH History=
 
You can see the history by executing  
 
You can see the history by executing  

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