Bash function

From thelinuxwiki
Revision as of 22:22, 25 February 2013 by Nighthawk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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"