bash - Passing a command to 'find -exec' through a variable does not work -
given directory $home/foo/ files in it.
the command:
find $home/foo -type f -exec md5deep -bre {} \;
works fine , hashes files.
but, creating variable -exec not seem work:
md5="md5deep -bre"
find $home/foo -type f -exec "$md5" {} \;
returns: find: md5deep -bre: no such file or directory
why?
since enclosing variable in double quotes, entire string gets sent find single token following -exec , find treats name of command. resolve issue, remove double quotes around variable:
find "$home/foo" -type f -exec $md5 {} \; in general, not store commands in shell variables. see bashfaq/050.
Comments
Post a Comment