Reputation: 115
We're moving some utilities from an old project to a new to-be-version-controlled one (on the same disk, under different usernames), and I've been tasked with finding utilities that are part of the old account but not the new one, and to find files that are different between the two accounts. The new account has been active for about a year and people have made (small) changes to some files in the old one without making them in the new one.
These utilities are on a remote server that I only have read access to (except my own home folder).
The old account, call it user1, has all its utilities in the ~user1/bin/ folder, including source, executable, and script for each utility.
The new account, say user2, has been set up in a way that each 'executable/script' in the ~user2/bin/ folder is a symlink to the appropriate file in the subfolder ~user2/src/{utilityname}/, which also contains the source for that executable.
Is there an easier way to compare the two directories than
find ~user1/bin/ -maxdepth 1 -printf '%s, %p\n' | sort -k2 > user1.txt
find -L ~user2/bin/ -maxdepth 1 -printf '%s, %p\n' | sort -k2 > user2.txt
and comparing the results manually to see what's different / missing?
Also, the above commands will only let me compare executables/scripts in the ~user2/bin/ folder, which can be different even if the source code in ~user2/src/{utilityname}/ is the same between user1 and user2 (because of different paths in scripts, for example). Is it possible to search the folder in which a utility's symlink target resides for a source file with the same name, so that I can compare source files between user1 and user2 directly?
Upvotes: 2
Views: 395
Reputation: 124
I would use a different approach: find files which have no duplicates. I suggest this thread, especially the part combining fdupes
, find
and grep
:
fdupes -r backup/ documents/ > dup.txt
find backup/ -type f | grep -Fxvf dup.txt
Though, it may need some more adjustments to adapt it to your needs, for example the use of fdupes' "-s" option.
Upvotes: 1