Ben Kim Ben Kim - 5 months ago 28
Bash Question

Shell Script call a function with a variable?

Hi I'm creating a shell script.

and an example code looks like


echo "It works!"

funcion_name = "test_func"

I want to somehow be able to call test_func() using the variable "function_name"

I know that's possible in php using call_user_func($function_name) or by sying $function_name()

is this also possible in the shell scripting?

Huge appreciation for the help! :)

test_func() {
    echo "It works!"


eval ${function_name}