Last modified: Mon Dec 7 09:58:22 2020
I would appreciate it if you occasionally buy me a coffee as it helps maintain this site. Thanks to those who do!
Check out my Sed Reference Chart (pdf)
Here is a quick reference to the major parts of SED, with links to my extended tutorial on commands, flags and options. I've placed it on this page to make my web site more mobile-friendly.
Unix Concepts | |
---|---|
Bypassing the shell by quoting characters | |
Regular Expressions |
Sed Pattern Flags |
---|
/g - Global |
/I - Ignore Case |
/p - Print |
/w filename - Write Filename |
Sed Command Line options | |
---|---|
Short Option (Long option) | Sed version |
-n | Classic |
-e script | Classic |
-f scriptfile | Classic |
-e script (--expression=script) | GNU sed |
-f scriptfile (--file=scriptfile) | GNU sed |
-h (--help) | GNU sed |
-n (--quiet --silent) | GNU sed |
-V (--version) | GNU sed |
-r (--regexp-extended) | GNU sed |
-i[SUFFIX] (--in-place[=SUFFIX]) | GNU sed |
-l N (--line-length=N) | GNU sed |
-b (--binary) | GNU sed |
-s (--separate) | GNU sed |
-z (--null-data) | GNU sed |
-u (--unbuffered) | GNU sed |
(--follow-symlinks) | GNU sed |
(--posix) | GNU sed |
-i SUFFIX | Mac OS X, FreeBSD |
-a | Mac OS X, FreeBSD |
-l | Max OS X, FreeBSD |
-E | Mac OS X, FreeBSD |
-r | FreeBSD |
-I SUFFIX | FreeBSD |
Sed Commands |
---|
: label |
# comment |
{....} Block |
= - print line number |
a \ - Append |
b label - Branch |
c \ - change |
d and D - Delete |
g and G - Get |
h and H - Hold |
i \ - Insert |
l - Look |
n and N - Next |
p and P - Print |
q - Quit |
r filename - Read File |
s/..../..../ - Substitute |
t label - Test |
w filename - Write Filename |
x - eXchange |
y/..../..../ - Transform |
I hope you find this useful.