Otherwise just navigate to the containing directory and open it in your favorite text editor. ![]() If you want to view the file from the command line, try: Opening the text file you’ll see something like this: Now look in the present working directory for the file you just created via outputting the diff command, in this case the file is musicfolders.txt and the contents can be viewed in any text editor, command line or otherwise. Let’s say w’re comparing folders named “old music” and “new music”, and we want the command output showing the difference between those two directories in the file named “musicfolders.txt” then the following command syntax would be used:ĭiff -rq "old music" "new music" > musicfolders.txt Here’s an example and how the actual printout will look. You can also go a step further and redirect the output of that command to a file, let’s say it’s named differences.txt:ĭiff -rq directory1 directory2 > differences.txt Only in directory2: MyFavoriteSpecialMovie.mp4 Only in directory1: SuperSecretDifferentFile.rtf Sample output of the command may look like the following: ![]() We are using the -rq flag because -r means it is recursive to include subdirectories, and -q simplifies the command output to only the differences shown. This executes the diff command comparing directory1 and directory2 (if you have a folder with a space in the file name, just put it in quotes like so: “folder one”). Hit return when you have specified the appropriate directories to compare. To get started, launch the Terminal in Mac OS (found in /Applications/Utilities/) and then use the following command syntax: How to Compare Contents of Two Directories with diff Diff is quite simple to use for easily comparing the contents of any two directories, just follow along by using syntax detailed below. To achieve this comparison, we’ll use the command line tool ‘diff’, diff is available on all Macs, along with linux and other unix operating systems, so this is effectively a cross-platform solution for comparing directories.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |