You might want to pipe the output to something like ‘more’ to make it easier to scan though: If you’d prefer not to create a text file with the changes, just leave off the output redirection of the command. 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. Press and hold the Command and Option keys on your keyboard, then click and drag the folder to the desktop.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. If you want to bring a file with you, you'll need to navigate to the actual location of the file and copy it to the flash drive. Also note that copying a shortcut onto a flash drive will not work. If you delete a shortcut, it will not delete the actual folder or the files it contains. ![]() It's simply a way to access it more quickly. Note that creating a shortcut does not create a duplicate copy of the folder. A shortcut will have a small arrow in the lower-left corner of the icon. Instead of navigating to the file or folder every time you want to use it, you can simply double-click the shortcut to open it. If you have a file or folder you use frequently, you can save time by creating a shortcut on the desktop. In the next lesson, we'll talk about another important concept: how to find files on your computer that you can't easily locate. You'll start to feel more comfortable as you continue using your computer. ![]() If working with files and folders feels a little tricky right now, don't worry! Like anything else, working with files and folders is largely a matter of practice.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |