Show Menu

Bash/ZSH Shourtcuts Cheat Sheet by

Keyboard shortcuts and expansion reference.
bash     linux     zsh     shortcut     expansion

Bash/ZSH Keyboard Shortcuts

Tab
Auto complete
^a
Beginning of line
^e
End of line
^f
Forward one character
^b
Back one character
^h
Delete one character (backw­ards)
%f
Forward one word
%b
Back one word
^w
Delete one word (backw­ards)
^u
Clear to beginning of line
^k
Clear to end of line
^y
Paste from Kill Ring
^t
Swap cursor with previous character
%t
Swap cursor with previous word
^p
Previous line in history
^n
Next line in history
^r
Search backwards in history
^l
Clear screen
^o
Execute command but keep line
^z
Suspend process
fg
restore process
bg
continue process in background
^c
Kill current process
^d
Exit shell
^ - Hold Control while pressing key
% - Hold meta (alt, or command on mac)
 

Bash Parameter Expansions

${pa­ram­eter}
Value of parameter
${pa­ram­ete­r:-­word}
Use default
${pa­ram­ete­r:=­word}
Assign default
${pa­ram­ete­r:?­word}
Display Error
${pa­ram­ete­r:+­word}
Use Alternate
${pa­ram­ete­r:o­ffs­et}
Substring
${pa­ram­ete­r:o­ffs­et:­len­gth}
${!n­ame­[@]}
List Array Keys
${#p­ara­met­er}
Parameter length
${pa­ram­ete­r#m­atch}
Remove prefix
${pa­ram­ete­r##­mat­ch}
(longest)
${pa­ram­ete­r%m­atch}
Remove suffix
${pa­ram­ete­r%%­mat­ch}
(longest)
${pa­ram­ete­r/p­att­ern­/st­ring}
Substi­tution
${pa­ram­ete­r^p­att­ern}
Uppercase match
${pa­ram­ete­r^^­pat­tern}
Uppercase all
${pa­ram­ete­r,p­att­ern}
Lowercase match
${pa­ram­ete­r,,­pat­tern}
Lowercase all

Rockstar Penguin

 

Sed commands

:[la­bel]
Set label
Zero/One address commands
=
Print current line number
a \
Append text
text
(embedded newlines)
Address range commands
b [label]
Jump to label
t (T) [label]
Jump to label on (failed) s///
c \
Replace match
text
(Embedded newlines)
d (D)
Delete (to newline)
h H
Copy/A­ppend pattern
g G
Paste/­Append hold
x
Exchange hold/p­attern
n N
Read/A­ppend next line
p
Print pattern
s/re­gex­/re­pla­ce/
Substi­tution
Addr­esses
firs­t~s­tep
Starting at first, every stepth
/reg­ex/
Lines matching regex
addr­1,+N
addr1 and N following lines
Vari­ous
{c1;­c2;­c3;}
List of commands
;
Separate commands
Using GNU Sed 4.2.2. Handy one-li­ners: http:/­/se­d.s­our­cef­org­e.n­et/­sed­1li­ne.txt

Download the Bash/ZSH Shourtcuts Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/davidsouther_bash-zsh-shourtcuts.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          bash Shortcuts Cheat Sheet
          Bash Script Colors Cheat Sheet