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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -