
This makes your results much easier to read! Of course, you can combine this with the "-r" option, too.

For example, you can use the "-r" option to force the command to search all subfolders, like so: diff -r Īnother often-used choice is "-q," which'll output less-detailed text that only tells you whether files differ and not how they differ. So that's all pretty handy, but you have a few options you can add on, too, to make things even better. (I typed "text differs" within one of them to show you how it'd look.)

In the window that appears, you'll configure your rule I see that one file only lives in the copy and is missing from the original folder: Only in /Users/melissa/Desktop/TMO Copy: Account Info.jpgĪnd I also find that a text file has different content than its counterpart: 7c7,9 From it, I can tell that I've got two JPEG files with the same name but different content: Binary files /Users/melissa/Desktop/TMO/20130524 Table.jpg and /Users/melissa/Desktop/TMO Copy/20130524 Table.jpg differ The thing is, though, that the gobbledygook is pretty interesting. Press Return to implement the command, and your Terminal window will fill with delicious data. That'll make Terminal fill in the paths to those folders for you, and you should see something like this: It doesn't matter what order you do this in, and you don't have to type a space in between, either. When you've got it ready to go, type diff in at the prompt followed by a space, and then drag the two folders you want to compare and drop them on the Terminal window. It's accessed through the Terminal, so first you'll open that program from your Applications> Utilities folder. A lot of folks don't know that there's a built-in way to do that, and it's pretty easy to use and understand. If there are directories and/or files that are present only in one of the folders, they will be listed as being only in that folder.Let's say you've copied an older version of a folder off of your backup drive, and you need to find out how its contents compare to the current version on your Mac. They are compared in terms of their contents. Will compare the directories folder and folder2 that are in the current working directory. diff -s example.txt example2.txt).ĭirectories are compared with the same command. In case, you want explicitly to be informed that the files are the identical, you can use the option -s (e.g. If the files are identical, no output will be shown. another-Another) won't be listed since it's a case difference. So with the above example, if we use the command diff -i example.txt example2.txt, the second difference between the files (e.g. For example, -b is for ignoring differences in terms of spaces, -w is for ignoring tabs and spaces, and -i is for ignoring case differences. Of course, you can compare other types of files, not just txt files (e.g.

The third line in the second file begins with a lower case letter as compared to the same line in the first file (e.g. In our example the first line in the first file is different from the same line in the second file because of a spelling mistake ( Tis instead of This). example.txt) have an opening bracket in front of them. The lines in the first file that we put in the command (e.g. In this case we can see that there are two lines in the files that are different. For example, let's say that we think that the above mentioned two example files are identical, but we're not exactly sure so we check by executing the command. When you execute the command, if there are any lines in the files that are different, they will be listed. diff /home/username/public_html/docs/example.txt /home/username/public_html/example2.txt).
COMMAND TO COMPARE FOLDERS FULL
Of course, if the files are in different folders on your hosting account you can use the full paths to the files (e.g. Will compare the files example.txt and example2.txt which are both in the current working directory.
COMMAND TO COMPARE FOLDERS HOW TO
Knowledgebase How to compare files and folders via SSHĬomparing file differences through SSH, and also comparing the contents of directories can easily be performed with the command diff.
