Reputation: 1
Let's say I have a script that generates incrementing folder names over time (100, 101, 102, 103, 104, etc...). These folders are synced between machines and there is a chance of creation failure for any given folder on system 2.
System 1 is always in sync: 100/ 101/ 102/ 103/ 104/ etc...
System 2 may have errors: 100/ 102/ 103/ etc...
(as you can see, 101/ & 104/ are missing on system 2)
How can I generate a list of all the missing folders on System 2?
P.S. Rsync is not really an option because the actual number of folders is incredibly high.
Upvotes: 0
Views: 1013
Reputation: 342591
you can use diff. assuming you had already mapped system2 to a path
diff system1/path system2/path
Upvotes: 0
Reputation: 880079
You could do something like this:
% ls -1 System1 > ls.System1 # Use the -1 flag to ensure 1 dir per line
% ls -1 System2 > ls.System2
% comm -23 ls.System1 ls.System2
101
104
The comm command can show you what is common to both, unique to f1, or unique to f2:
comm -12 f1 f2 # common to both
comm -23 f1 f2 # unique to f1
comm -13 f1 f2 # unique to f2
Upvotes: 1
Reputation: 838536
You can pipe the contents of ls
on each machine to a file, and then diff the two files. You can also use the command comm
to show lines that are only in one file, and not in the other.
Upvotes: 2