You are on page 1of 1

Bash/ZSH Shourtcuts Cheat Sheet

by DavidSouther via cheatography.com/2124/cs/1151/

Bash/ZSH Keyboard Shortcuts

Bash Parameter Expansions

Sed commands

Tab

${parameter}

Value of

:[label]

parameter

Zero/One address commands

End of line

${parameter:-word}

Use default

Print current line number

Forward one character

${parameter:=word}

Assign default

a\

Append text

Back one character

${parameter:?word}

Display Error

text

(embedded newlines)

Delete one character (backwards)

${parameter:+word}

Use Alternate

Address range commands

Forward one word

${parameter:offset}

Substring

b [label]

Jump to label

%b

Back one word

${parameter:offset:length}

t (T) [label]

Jump to label on (failed) s///

^w

Delete one word (backwards)

${!name[@]}

List Array Keys

c\

Replace match

Clear to beginning of line

${#parameter}

Parameter length

text

(Embedded newlines)

Clear to end of line

${parameter#match}

Remove prefix

d (D)

Delete (to newline)

Paste from Kill Ring

${parameter##match}

(longest)

hH

Copy/Append pattern

Swap cursor with previous character

${parameter%match}

Remove suffix

gG

Paste/Append hold

Swap cursor with previous word

${parameter%%match}

(longest)

Exchange hold/pattern

^p

Previous line in history

${parameter/pattern/strin

Substitution

nN

Read/Append next line

^n

Next line in history

Print pattern

^r

Search backwards in history

s/regex/replace/

Substitution

^l

Clear screen

^o

Execute command but keep line

^z

Suspend process

fg

restore process

bg

^a
^e
^f
^b
^h
%f

^u
^k
^y
^t
%t

Auto complete
Beginning of line

g}
${parameter^pattern}

Uppercase match

${parameter^^pattern}

Uppercase all

${parameter,pattern}

Lowercase match

${parameter,,pattern}

Lowercase all

Set label

Addresses
first~step

Starting at first, every


stepth

/regex/

Lines matching regex

continue process in background

addr1,+N

addr1 and N following lines

^c

Kill current process

Various

^d

Exit shell

{c1;c2;c3;}

List of commands

Separate commands

Rockstar Penguin

^ - Hold Control while pressing key


% - Hold meta (alt, or command on mac)

Using GNU Sed 4.2.2. Handy one-liners:


http://sed.sourceforge.net/sed1line.txt

By DavidSouther

Published 18th July, 2013.

Sponsored by Readability-Score.com

cheatography.com/davidsouther/

Last updated 22nd July, 2013.

Measure your website readability!

Page 1 of 1.

https://readability-score.com

You might also like