Editing output using sed
The sed
command is a non-interactive stream editor that allows you to modify the content of the standard input or file. It performs an operation on each line in a pipeline. The syntax will be:
sed [OPTIONS]... {script} [input-file …]
By default, the output is displayed on stdout
, but can be redirected to a file if specified.
The input-file
are the files on which sed
needs to be run. If no files are specified, it reads from stdin
.
The script
can be a command or a file with multiple commands to pass to sed
, and OPTIONS
to sed
are described in the following table:
Option |
Description |
---|---|
-n |
This suppresses automatic printing of pattern space |
-e script |
This allows multiple scripts to be executed |
-r |
This uses the extended regex ... |
Get Linux Shell Scripting Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.