What is Sed? Learn about the Sed command in Linux
Sed is a line editor, commonly used to change text in files on the Linux operating system.

Sed is an extremely useful command line utility for editing text, searching and replacing strings, deleting lines, inserting lines and many other operations. This article from TipsMake will give you an overview of what is Sed? basic usage of Sed.
What is the Sed command?
Sed is a stream editor, commonly used to change text in files. It stands for 'stream editor'. Sed reads each line of text from the input, makes the specified changes, and then outputs the results. The changes are identified using regular expressions (regex). This makes it a highly efficient tool for managing and editing text, especially when working with large files or automating tasks in commands.
Syntax of Sed command in Linux
The basic syntax of the sed command is as follows:
sed [options] 'command' file
In there:
- options are options to customize sed's behavior, such as -n to disable the default line printing mode or -i to directly change the input file.
- command is one or more commands to be executed for each line of the file.
Commonly used options in Sed command
sed [OPTIONS]. {script-only-if-no-other-script} [input-file].
Options:
Here are some command line options of the sed command:
-n, --quiet, --silent: Enable forced printing of pattern space.
–help: print command usage information.
-f script-file, --file=script-file: Used to append the contents of the script-file to the commands to be executed.
--follow-symlinks: Follow symbolic links when processing in-place.
–posix: Disable the POSIX sed extension to simplify writing portable scripts.
-l N, --line-length=N: Used to specify the desired line break length for the `l' command.
-E, -r, --regexp-extended: Allows us to use extended regular expressions in the script (for ease of conversion, use POSIX -E).
-i[SUFFIX], --in-place[=SUFFIX]: Used to edit files in place.
-s, --separate: used to treat the files as separate instead of as a single file and continue the long stream.
--sandbox: Disable external programs and only operate on input files on the command line.
-u, --unbuffered: Used to load minimal amount of data from input files and flush output buffers more frequently.
-z, --null-data: Used to separate lines with the NUL character.
--help: used to display help instructions.
--version: Used to display version information.
What is the Sed command?
Detailed instructions on how to use the Sed command
Some systems have the sed command built into the machine, but some do not. Therefore, to know if the machine can use the sed command or not, you need to check with the command: sed --version.
If not, please install according to your operating system using the following commands:
- Ubuntu/Debian: sudo apt-get install sed
- CentOS/RHEL: sudo yum install sed
- macOS (with Homebrew): brew install gnu-sed
Once installed, you can start using the sed commands presented in the next section of the tutorial.
Conclude
The sed command is an indispensable tool in the toolkit of any Linux system administrator, as well as anyone who works regularly with the command line. From simple operations to complex ones, sed allows you to process text efficiently and flexibly.
Through this article of TipsMake, hopefully you have grasped the basic knowledge about sed and can confidently apply it to your work.
You should read it
- The unlucky customers who bring iPhone to the Apple Store, there's no way to get it back
- Top 10 best antivirus websites, virus scanning online 2020
- What is cyanide poison? How dangerous is cyanide poison?
- Top 30 good games on android update 2021
- TOP best offline games on PC
- Try being a hacker with these 4 hacking simulators!
- Official Torchlight Infinite launch date
- More than 450,000 backup batteries sold on Amazon recalled due to fire risk
- A set of JavaScript multiple-choice questions with P5 answers
- Unexpectedly discover the new unique hermit crab in South Africa
- A simple way to help your body retain its natural fragrance all day long
- How to create a new channel on YouTube?
Maybe you are interested
Learn about BASIC: The programming language that just turned 60 years old Cheat Engine - Download Cheat Engine here Instructions for creating Facebook Avatar animated version of yourself How to create a Facebook avatar wearing a Covid-19 season mask How to show / hide fonts in Windows 10/8 Top black avatar for sad mood