compare directory contents plus copy differences?
Posted: Fri 22 Feb 2019, 01:56
HI, coding problem.
I have
Which compares two directories and tells me what's missing.
Currently I change it to
To give me a file listing the missing files.
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
But I don't know what to put in the ??? part?
Or is there a better way?
Can I have some help please.
thanks in advance.
I have
Code: Select all
diff <(cd directory1 && find . | sort) <(cd directory2 && find . | sort)
Currently I change it to
Code: Select all
diff <(cd directory1 && find . | sort) <(cd directory2 && find . | sort) >difffile
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
Code: Select all
#!/bin/sh
#involk as cmpsrt directory1 directory2
#outputs directories dir1-missing-dir2 and dir2-missing-dir1
#containing the contents missing in both ways
#
mkdir $1-missing-$2
mkdir $2-missing-$1
diff <(cd $1 && find . | sort) <(cd $2 && find . | sort)
???
Or is there a better way?
Can I have some help please.
thanks in advance.