Working from home, the contents of my laptop undergoes a lot of changes. Before lockdown, I was usually in the office, and I could manually mirror files to a network drive.
Working from home means no network access. I have to compare the network drive contents to the laptop drive contents using a listing command such as:
touch ~/tmp/2021-07-25.txt -d 2021-07-25 stdbuf -i0 -o0 -e0 \ find ~/!(tmp) ~/.[^.]* \ -type f -newer ~/tmp/2021-07-25.txt \ -printf '%p\t%CY%Cm%Cd.%CH%CM\t%s\n' \ 2>&1 | tee ~/tmp/find.out
The "stdbuf" command simply disables buffering for the ensuing command so that I can see signs of life. The file/folder arguments to "find" exclude "tmp" and include all the files/folders starting with ".", but not the current folder "." itself and not the parent folder "..". The printf clause prints out the file information in the format:
File path <tab> YYYYMMDD.HHmm <tab> size YYYY = 4-digit year MM = 2-digit month DD = 2-digit day-of-month HH = 24-hour hour MM = 2-digit minute
The above is for the laptop. I can remote in to the on-site desktop and do a similar listing of my network drive for comparison. There, find's file/folder arguments consist only of "/i" (the letter-drive mapping of the network drive). That top folder doesn't contain files/folders starting with ".". I have to clean up the two listings to avoid the discrepancy between "~" and "/i".
My next step is to "diff" the listings from the laptop and the network drive. Unfortunatley, diff is easily thrown off by the commonality in the "dirname" portions of the path. I tried modifying find's printf format to obtain:
Basename <tab> File path <tab> YYYYMMDD.HHmm <tab> size
Unfortunately, diff is easily misled to match files based on initial few characters.
What I really want is for diff to match lines based on the file path, then match characters thereafter, i.e., based on the YYYYMMDD.HHmm stamp, then on the size. Is there a way to steer diff into doing this?
Afternote: I'm using Cygwin on both ends. Unfortunately, being in a Windows environment, names of files shared with (or coming from) others have spaces. Some folder names also have punctuations and spaces. If needed, I can mitigate the problem by embedding a marker (e.g., "QQQQ") after the file path, but the fields in find's output are already delimited by <tab>. I still need "diff" to match lines based on the entire file path, then look for discrepancies (if any) after the file path field.