Closed Captioning Closed captioning available on our YouTube channel

How to use the diff command: 2-Minute Linux Tips

Network World | Jul 24, 2020

In this Linux tip, learn how to use the diff command. It’s one of a number of commands that can report on file differences. If the files are text files, the command will display the differences line by line. If they’re some other kind of files – image files or binaries, diff will only tell you whether the files are the same or different.

Copyright © 2020 IDG Communications, Inc.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the diff command. It’s one of a number of commands that can report on file differences. If the files are text files, the command will display the differences line by line. If they’re some other kind of files – image files or binaries, diff will only tell you whether the files are the same or different.
Comparing two image files, we might see this:
Comparing two text files, however, we see which lines exist in one file or the other. Lines in the output that start with < tell you that they’re in the first of the two files while output lines starting with > mean the opposite. In the example below, we use diff to show us the differences between the attendance lists for two different meetings. The files also both seem to have a heading that identifies the month of that meeting.
Notice that one of the attendees (Karen Bartlett) was at the July meeting, but not the June meeting. All the others were at the June meeting and not the July meeting since their names are on both files.
One important thing to remember is that the lines in text files have to be in the same order for diff to work as expected since it compares text files line by line.
That’s your Linux tip for the diff command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.

Popular
Featured videos from IDG.tv