8 Uses of sed in Linux

A super weapon for text editing in Unix-like systems

Yang Zhou
TechToFreedom

--

Image from Wallhaven

In Unix-like operating systems, there is a text editing utility called sed, which stands for “stream editor”.

It’s not beginner-friendly at the first glance and you probably like to use interactive text editing tools in most cases.

However, for these scenarios:

  1. You are writing automation scripts, which is not possible for interactive editing.
  2. There is too much repetitive editing work.
  3. Some editing operations are too complex to be handled in an interactive text editor.

They are the showtime of sed. Of course, you can use Perl or Python to do complex text editing as well. But sed, as a built-in tool of a majority of Unix-like OS, is the best example to show how elegant and simple Unix/Linux is. 😎

It’s worth knowing sed for all developers. Even if you never use Linux systems.

Given that the sed is a super weapon of text editing, its syntax and tricks can be written into a thick book (just like awk). But for daily operations, you probably don’t need to know all the details.

This article will introduce 8 must-know sed uses through many easy-to-understand examples. If you can master them, you…

--

--