1/23
Practice flashcards covering the definitions, options, syntax, and specific commands of the sed stream editor based on lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
sed (Stream Editor)
A non-interactive, line-oriented stream editor that processes one line at a time and is used for text processing and in-place substitution.
-r option
An option that makes regular expressions work better by correctly recognizing characters like ( ), [ ], *, and +.
s command
The substitution command used to replace occurrences of a matched regex pattern with specific text, following the syntax [address(es)]s/pattern/replacement/[flags].
g flag
A global match flag placed after the last delimiter in a substitution command to replace all occurrences of a pattern in the pattern space.
-i option
An option used to make permanent changes to a file by performing editing in-place.
-n option
An option that suppresses automatic output, ensuring that only lines specified with a print command or 'p' flag are displayed.
-f script
An option indicating that the next argument is a filename containing editing commands.
-e command
An option used when the next argument is an editing command rather than a filename, useful for specifying multiple commands.
Pattern Space
A temporary buffer where sed copies each line of input to apply editing commands.
Address
A component of a sed command, consisting of a line number or regular expression, that determines which lines in the input file are processed.
! operator
A complement operator used to negate an address, applying the associated command only to lines that do NOT match the address.
d command
A deletion command that removes addressed lines from the pattern space and prevents them from being passed to standard output.
{ } braces
Used to group and apply multiple commands to a specific address or address range.
p command
A command used to force the output of the pattern space, typically used when the -n option is specified.
& (ampersand)
A special character used in the replacement string of a substitute command that represents the entire string matched by the regular expression.
\n (backreference)
A replacement pattern character replaced by the nth substring or sub-expression previously specified using '(' and ')'.
a command
The append command used to add text after the addressed line; it must be specified on multiple lines as [address]a\ text.
i command
The insert command used to add text before the addressed line, following the syntax [address]i\ text.
c command
The change command used to replace addressed lines with new text, using the syntax [address(es)]c\ text.
r command
The read command used to queue the contents of a filename to be inserted into the output stream at the end of the current cycle.
w command
The write command used to write the current pattern space to a specified filename, which is created or truncated before reading.
= command
The line number command which writes the current line number before each matched or output line.
y command
The transform command which performs a one-to-one character-to-character replacement, similar to the tr command.
q command
The quit command which terminates the sed script once the specified address is encountered.