PDA

View Full Version : Comparing 2 Directories



Hiko
29th May 2006, 09:18 PM
Aloha,
Anyone have a good link or inforamtion on how to compare all the files in 2 Directories and have it saved so I can look through it. My situation is this. I have 2 Music directories, BackupMusic and Music. Both are in my home directory. I know that there are songs that are not in both directories so I want to find these, and eventaully have all my music in one directory. I was thinking grep but I am not sure if it woul work.
Thanks,
Edward

u-noneinc-s
29th May 2006, 09:34 PM
I don't know if this is "exactly" what you're looking for. I have 2 Eagles dirs. /fat/music/Eagles and ~/Media/Music/Eagles so
the command diff /fat/music/Eagles ~/Media/Music/Eagles .~/Eagles Will check both dirs and redirect (>) the output to ~/Eagles.
I run the comnmand and check the file...
mark@spongie 151 /home/mark =>diff /fat/music/Eagles ~/Media/Music/Eagles > ~/Eagles

mark@spongie 152 /home/mark =>more Eagles
Only in /fat/music/Eagles: Desperado
Only in /fat/music/Eagles: Eagles
Only in /fat/music/Eagles: Hell_Freezes_Over
Only in /fat/music/Eagles: Hotel_California
Only in /fat/music/Eagles: One_of_these_Nights
Only in /fat/music/Eagles: On_the_Border
Only in /fat/music/Eagles: Smugglers_Blues.mp3
Only in /fat/music/Eagles: The_Heat_Is_On.mp3
Only in /fat/music/Eagles: The_Long_Run

Edit: I haven't read the man on diff, but maybe it will dig deeper into the subdirs as well. (notice it found files
and dirs, but didn't list the contents of those dirs)

u-noneinc-s
29th May 2006, 09:39 PM
--recursive will check sub dirs

Hiko
29th May 2006, 09:50 PM
Aloha,
Thanks. I used the following:
diff -r /home/edward/Music /mnt/external_hdd/BackupMusic/music > music_diffs.txt
and it output a file with all the differences. Now, I need to go through all of the texs and make the differences disappear. Thanks for the help.
Edward

Hiko
29th May 2006, 09:50 PM
Aloha,
Also I didn't know how to do the code: thingy.
Mahalo,
Edward

u-noneinc-s
29th May 2006, 10:41 PM
Glad I could help