Last active
July 3, 2023 05:14
-
-
Save sebastiancarlos/3bd8cdd8b5e045cf9537abaf28d8b4a6 to your computer and use it in GitHub Desktop.
GNU sed commands cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Command | Output Stream | Pattern Space | Hold Space | Jump to | |
---|---|---|---|---|---|
= | print line number | ||||
a TEXT | queue printing TEXT after the default print | ||||
r FILENAME | queue printing content of FILENAME after the default print | ||||
R FILENAME | queue printing a line of FILENAME after the default print | ||||
i TEXT | print TEXT | ||||
c TEXT | print TEXT | delete | end-of-cycle | ||
d | delete | end-of-cycle | |||
D | delete first line | beginning of cycle (or end-of-cycle if 'Pattern Space' is empty) | |||
e | run 'Pattern space' as shell command and replace with output | ||||
s/// | run substitution | ||||
y/// | run transliteration | ||||
b [LABEL] | LABEL (end-of-cycle if no LABEL) | ||||
t [LABEL] | LABEL if last 's' successful (end-of-cycle if no LABEL) | ||||
T [LABEL] | LABEL if last 's' unsuccessful (end-of-cycle if no LABEL) | ||||
g | replace with content of 'Hold Space' | ||||
G | append the content of 'Hold Space' | ||||
h | replace with content of 'Pattern Space' | ||||
H | append the content of 'Pattern Space' | ||||
x | exchange | exchange | |||
z | delete | ||||
p | print 'Pattern Space' | ||||
P | print first line of 'Pattern Space' | ||||
l | print 'Pattern Space' (in debug form) | ||||
n | print 'Pattern Space' if there's no -n flag | replace with next input line | exit if there was no next input line | ||
N | append next input line | exit if there was no next input line | |||
q | print 'Pattern Space' if there's no -n flag | exit | |||
Q | exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment