Bash function

From thelinuxwiki
Jump to: navigation, search

bash function structure

 functions function_name {
   command 1
   command 2
   ...
 }


function with argument and return string

#!/bin/bash
function pass_back_a_string() {
        eval $1=foo
}
return_var=
pass_back_a_string return_var
echo $return_var

Prints "foo"