What I want to do is take this one step further and after creating another pair of directories called directory1-missing-directory2 and directory2- missing-directory1 have these new directories populated with a copy of whats missing.
so I think it becomes something like
#involk as cmpsrt directory1 directory2
#outputs directories dir1-missing-dir2 and dir2-missing-dir1
#containing the contents missing in both ways
diff <(cd $1 && find . | sort) <(cd $2 && find . | sort)
Joined: 23 Mar 2009 Posts: 651 Location: Western United States
Posted: Thu 28 Feb 2019, 19:40 Post subject:
Here's a crude script that illustrates a solution:
# arguments are dir1 and dir2, relative to pwd
if [ $# != 2 ]; then
echo "needs 2 args"
find . >$list1
find . >$list2
cat $list1 $list2 | sort >$listall
uniq -u $listall > $listdiff
cat $list1 $listdiff | sort | uniq -d >$list1not2
cat $list2 $listdiff | sort | uniq -d >$list2not1
# Now list1not2 contains the list of files in d1 but not in d2
# and similarly for list2not1
It doesn't actually create and populate the difference directories, but once you've got the two files that list the deltas, the rest is trivial. I leave that and the elimination of the tmp files as an exercise for the reader.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum