[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash - executing function in "find" command



Hi,
bash command "find" let's you execute other commands like this:
$find . -exec commandname {} param1 param2 \;
This should do: for each file in actual directory tree run:
$commandname filename param1 param2
("{}" stands for filename)
So far I understood it from manuals and it's running as I want.
But I want to use bash function instead of command. Somehow, I can't get
to run function like this. If I run:
$find . -exec functionname {} par1 par2 \;
I get a message:
find: functionname: No such file or directory
find: functionname: No such file or directory
find: functionname: No such file or directory
.....
for each file in actual directory tree. Of course I defined function
before.
Problem is not, that command "find" runs in different environment, and
doesn't know variables and functions from parent shell. Because i tried:
A="XXX"
$find . -exec echo $A \;
XXX
XXX
XXX
XXX
XXX
XXX
$
And I also tried:
export -f functionname(){
.....
}

Which also didn't help. 
Somebody has a idea how to run function there?
Thanks alot
   Dexter2



Reply to: