An ad-free and cookie-free website.
Learn to automate the editing of text files at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux sed Command Summary with Examples (3:38)
Our fortieth word, or command to memorize is
sed from our category
sed allows you to edit a stream of
||Print help screen|
||Add SCRIPT of commands to be executed|
||Command to substitute FIRST word for SECOND|
Recall from the last 10 videos, we sorted, cut, pasted, joined and searched text files, and now we'll conclude a 10-video set on text processing with a very brief introduction to the concept of automated editing.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
sed command has
13 traditional options, and the argument represents the
file you'd like to review.
Like most commands, help is available with double-dash
--help. And also make note, we're
entering the realm of programming languages here, and
grep in the last video, and others we
won't cover include:
are very deep, so people only have time to master a few.
sed offers the ability to
write, and implement scripts using the
-f option. And programs like
sed have what I'll call sub-commands,
/s is a very basic one here.
So why is
sed an important command?
Well, not only do we need to find patterns in text, but to automate
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Remember from the previous video on
grep, we saw that we misspelled
"third" as "thrid" in file
sed with the
's/thrid/third/' within single quotes
video20.txt, which is the argument,
and we're going to write that to
And then we'll
cat it here to verify
that it was done correctly.
And last, let's throw in the
/p at the end, to print the
sed has a lot of functionality.
We're only touching the surface here.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
So to fully explore its possibilities, you'll need a book dedicated to
sed. It's that vast.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
I suggest supplement the text here with videos on YouTube as two modes of learning will help this material stick.
grepcommand, hit Back.
calendar, click Next.
A newly-updated free resource. Connect and refer a friend today.