Cheatography
https://cheatography.com
Keyboard shortcuts and expansion reference.
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 (backwards) |
%f |
Forward one word |
%b |
Back one word |
^w |
Delete one word (backwards) |
^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
${parameter} |
Value of parameter |
${parameter:-word} |
Use default |
${parameter:=word} |
Assign default |
${parameter:?word} |
Display Error |
${parameter:+word} |
Use Alternate |
${parameter:offset} |
Substring |
${parameter:offset:length} |
${!name[@]} |
List Array Keys |
${#parameter} |
Parameter length |
${parameter#match} |
Remove prefix |
${parameter##match} |
(longest) |
${parameter%match} |
Remove suffix |
${parameter%%match} |
(longest) |
${parameter/pattern/string} |
Substitution |
${parameter^pattern} |
Uppercase match |
${parameter^^pattern} |
Uppercase all |
${parameter,pattern} |
Lowercase match |
${parameter,,pattern} |
Lowercase all |
|
|
Sed commands
:[label] |
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/Append pattern |
g G |
Paste/Append hold |
x |
Exchange hold/pattern |
n N |
Read/Append next line |
p |
Print pattern |
s/regex/replace/ |
Substitution |
Addresses |
first~step |
Starting at first, every stepth |
/regex/ |
Lines matching regex |
addr1,+N |
addr1 and N following lines |
Various |
{c1;c2;c3;} |
List of commands |
; |
Separate commands |
|
Created By
Metadata
Favourited By
and 52 more ...
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets