Learn To Use Functions
Mar 30, 2010, 12:33 (0 Talkback[s])
[ Thanks to Andrew
Weber for this link. ]
"Functions
"A function can help you modularize your script. In addition,
the function is executed in the context of the same shell, no child
process. This will save on resources as you use functions.
Functions are a script within a script which can be defined by the
user and stored in memory, allowing you to reuse the function
repeatedly. This also provides a modular aspect that allows you to
debug one function at a time be disabling functions.
"Think of functions as miniature shell scripts, or containers
inside a shell script where each container functions within itself
to provide resources for the larger script. One big difference
between a shell script and a function is that a new instance of the
shell is started for a shell script but the function runs in the
current shell"
Complete
Story
Related Stories:
- Bash History: Display Date And Time For Each Command(Mar 14, 2010)
- Deferrable functions, kernel tasklets, and work queues(Mar 12, 2010)
- Scripting the Vim editor, Part 5: Event-driven scripting and automation(Mar 10, 2010)
- Determine If Shell Input is Coming From the Terminal or From a Pipe(Feb 12, 2010)
- Prevent shell from exiting in single ^D(Jan 16, 2010)
- Tech Tip: Dereference Variable Names Inside Bash Functions(Jan 15, 2010)
- The C Programming Language(Jan 12, 2010)