Mon 04 Oct 2010 12:42:35 PM UTC, original submission:
Using diff 4.4.2 in MSYS.
I wanted a quick way to capture file name, size, modification and md5sum all in one tab separated line. I decided to use find -exec, and learned the limitation of the -exec commands. So I wrote a small shell function (below), which does what I want.
function f_md5stat ( )
{
stat --printf="%n\t%s\t%y\t$md5" $1; md5sum "$1" | cut -d\ -f1;
}
However, find can not access anything in the shell's environment. Not sure if that is by design, but seems to be an odd limitation.
I put the function into a file and put the file into /bin, for a quick test, and it will work that way. However, I wish to have several functions in one file. The workaround I have found is to use a "case" to detect the way the script was called (or what the 0th or 1st arguments were), and use that to determine which internal shell function to use.
The other custom function will call find on 2+ directory trees, pass each argument to the f_md5stat function, to generate detailed lists, which I will then use for the purpose of comparing and (for now, manually) synching files.
|