sed Flags & Options
Stream editor for filtering and transforming text.All sed pages
- sed -e: run several expressions in one sed commandsed -e adds an expression to the script, so one sed call can run several commands in order. When -e differs from a semicolon (a, i, c) and when -e is required.
- sed -E: use extended regular expressions (same as sed -r)sed -E (or -r) enables extended regular expressions: + ? | ( ) and {n} work without backslashes. BRE vs ERE table, literal parentheses and portable syntax.
- sed -n: suppress automatic printing (and why lines print twice)sed -n turns off automatic printing, so only p, s///p and = produce output. Why lines print twice without it, the #n script header, and the sed -n -i trap.
- sed -z: replace newlines and match across lines (null-separated data)sed -z splits input at NUL bytes, so a text file becomes one record and newlines can be matched. Join lines with commas, edit across lines, handle find -print0.