The sed
command in Unix is a stream editor used for performing basic text transformations on an input stream (a file or input from a pipeline). It is often used for tasks such as search and replace, deleting lines, inserting lines, and more.
Syntax of sed command
command
: The operation to perform on the input text.file
: The file on whichsed
will operate. If no file is specified,sed
reads from standard input (stdin).options
: Optional flags that modifysed
's behavior.
Common sed
Commands and Usage:
1. Search and Replace
The most common use of sed
is for search and replace. It uses the syntax:
s/old_text/new_text/
: This command searches forold_text
and replaces it withnew_text
.
Example:
No comments:
Post a Comment