Tuesday, August 28, 2012

How to import functions in a bash script?

I found this nice post in ubuntuforum.org: http://ubuntuforums.org/showthread.php?t=664657


Re: $bash - how to import functions in a file

you can create a file of frequently used variable, functions, etc in a ".cfg" file and then at the top of your script include one of these lines... they all do the same thing!
Code:
. $HOME/prefs.cfg
Code:
$include $HOME/prefs.cfg
Code:
source $HOME/prefs.cfg
I found this solution in the "Bash Cookbook" (Albing, Vossen, & Newham)...every bash scripter should have a copy of this book within each reach!

No comments:

Post a Comment