I'm on Solaris 10 and I have tested the following with ksh (88), bash (3.00) and zsh (4.2.1).The following code doesn't yield any result:function foo {    echo Hello World}find somedir -exec foo \;The find does match several files (as shown by replacing -exec ... with -print), and the function works perfectly when called outside from the find call.Here's what the man find page say about -exec: -exec command       True if the executed command  returns  a                     zero  value  as  exit status. The end of                     command must be punctuated by an escaped                     semicolon (;).  A command argument {} is                     replaced by the current pathname. If the                     last  argument  to  -exec  is {} and you                     specify + rather than the semicolon (;),                     the command is invoked fewer times, with                     {} replaced by groups of  pathnames.  If                     any  invocation of the command returns a                     non-zero  value  as  exit  status,  find                     returns a non-zero exit status.I could probably get away doing something like this:for f in $(find somedir); do    foodoneBut I'm afraid of dealing with field separator issues.Is it possible to call a shell function (defined in the same script, let's not bother with scoping issues) from a find ... -exec ... call?I tried it with both /usr/bin/find and /bin/find and got the same result.
Executing user defined function in a find -exec call
shell script;find;solaris;ksh;function
A function is local to a shell, so you'd need find -exec to spawn a shell and have that function defined in that shell before being able to use it. Something like:find ... -exec ksh -c '  function foo {    echo blan: $@  }  foo $@' ksh {} +bash allows one to export functions via the environment with export -f, so you can do (in bash):foo() { ...; }export -f foofind ... -exec bash -c 'foo $@' bash {} +ksh88 has typeset -fx to export function (not via the environment), but that can only be used by she-bang less scripts executed by ksh, so not with ksh -c.Another option is to do:find ... -exec ksh -c   $(typeset -f foo)'  foo $@' ksh {} +That is, use typeset -f to dump the definition of the foo function inside the inline script. Note that if foo uses other functions, you'll also need to dump them as well.