linux - find -exec a shell function? -
is there way find
execute function define in shell? example:
dosomething () { echo "doing $1" } find . -exec dosomething {} \;
the result of is:
find: dosomething: no such file or directory
is there way find
's -exec
see dosomething
?
since shell knows how run shell functions, have run shell run function. need mark function export export -f
, otherwise subshell won't inherit them:
export -f dosomething find . -exec bash -c 'dosomething "$0"' {} \;
Comments
Post a Comment