Difference between revisions of "Bash function"

From thelinuxwiki
Jump to: navigation, search
(Pushed from Themanclub.)
 

Latest revision as of 22:22, 25 February 2013

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"