In a script, I have:
CMD='/usr/bin/find /etc -type f -exec /usr/bin/md5sum {} \; '
MD5=$("${CMD}")
But the script gives the error:
-bash: /usr/bin/find /etc -type f -exec /usr/bin/md5sum {} \; : No such file or directory
However the contents of the $CMD work when typed verbatim at the command line, i.e.
/usr/bin/find /etc -type f -exec /usr/bin/md5sum {} \;
Correctly generates a list of md5 hashes.
I've tried everything I can think of, including escaping the backslash and semicolon in the string, but can't seem to get it to work.
I've also tried invoking the command with backticks, which doesn't change the result.
What am I doing wrong ?