Learn to compare and merge two files at the Linux command line.
Linux sdiff command summary with examples (3:48)
Videos can also be accessed from the YouTube Playlist.
Our thirty-sixth word, or command to memorize is
sdiff from our category
sdiff allows you to compare and
merge two files.
comm videos before this, we're
reviewing files comparison alternatives, and now
sdiff adds the functionality to merge
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
sdiff command has
20 options, and the arguments are the
two files you'd like to compare and merge.
Like most commands, help is available with double-dash
--help. The options here are not quite
as advanced as with
diff, but more
The one option I'd like to draw your attention to here is
-o which offers the ability to
interactively merge files.
So why is
sdiff an important command?
Well, you might want to debug changes to code.
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. Let's first take a quick look at files we've been comparing for this, now our third example of comparison commands.
We can use
sdiff without options, and
the first argument is
it had an incorrect date if you recall, and then
video35.txt is the corrected version.
Next, let's use the
sdiff with the
-o option, give it a file name
video36.txt, then our two arguments
Interactively, means it will prompt you with this
% symbol and here I'll use
r for the file on the right, but I
could pick a line on the left if I wanted.
And last, let's do a quick
cat of the
video36.txt to verify.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
sdiff provides you with a third
command to compare files, I suggest studying up and then picking your
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you learned something please consider subscribing to our YouTube Channel.
commcommand, hit Back.
pastecommand, click Next.