The following terminal operations are not a problem
find testDir -type f -exec md5sum {} \;
Where testDiris the directory containing some files (for example, file1, file2 and file3).
However, I get an error using the following in Java
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("find testDir -type f -exec md5sum {} \\;");
Error
find: missing argument to `-exec'
I believe that I am avoiding characters correctly. I have tried several different formats and I cannot get this to work.
UPDATE @jtahlborn answered the question perfectly. But now the team has changed a bit to sort each file in the directory before calculating md5sum and as follows (I already accepted a great answer to the original question so that I could buy a beer if they can come up with a format for this. I tried every combination I can come up with following answer without success.)
"find testDir -type f -exec md5sum {} + | awk {print $1} | sort | md5sum;"
, , , .
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(new String[]
{
"sh", "-l", "-c", "find " + directory.getPath() + " -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum"
});