BASH Concepts

A bash function is nothing but subroutine a portion of code within a larger script, to performs a specific task. For example, a function called die() can be used to display an error message and exit from the script. Under bash you can simply declare and use functions in the same file. Another option is to create a library of all useful functions and include that file at the start of the script.

Creating Function

You can create a simple function called myip as follows:

myip() { lynx --dump http://www.cyberciti.biz/files/what-is-my-ip-address.php | grep 'Your IP add' | cut -d: -f2; }

Invoking myip() function

The code defined by myip() function is not executed until the function is called. myip() function can be used like normal command. To execute myip(), simply type:

myip

SITES COURTESY:

www.cyberciti.biz

LETS LEARN AND START BASH PROGRAMMING:

http://ryanstutorials.net/bash-scripting-tutorial/

http://guide.bash.academy/01.inception.html#

eof