Table of Contents
Match files from different directories in pairs according to their basename and output the results where a match has succeeded, printing two filenames per-line of output.
This can be used to implement processing in two similar directories, for example, combining it with xargs:
match-files -x '--single' dir1/*.c dir2/*.c | xargs -n2 xxdiff
will result in:
xxdiff dir1/file1.c dir2/file1.c xxdiff dir1/file2.c dir2/file2.c xxdiff dir1/file3.c dir2/file3.c ...
The way we implement the heuristic to match up files is simple: we match up the basenames of the files. The files are always printed in the order that they show up on the command-line.
Also, you can match the file extensions instead of the basename as the matching string to implement a sort of 'zip' of the filenames, e.g.:
match-files -e file1.{h,cpp} file2.{h,cpp} | xargs -n2 mv
will result in:
mv file1.cpp file2.cpp mv file1.h file2.h
By default, a matching filename is printed out only when there are exactly 2 files matching the matching part. This number can be changed with an option.
match-files [<options>] [<file> ... (many files...) ]
Important
This computer program or library is provided for free. I am aware that some of the programs that I provide for free allow people to get their work done faster or better, save them time and money. If you are using this program for benefit, especially if you are using it within a commercial environment and it saves you time or work, please consider making a donation by sending me a book from my Amazon Wishlist or by a direct donation to my company's PayPal account by clicking on the link below.