Functions in Shell Scripts
Functions are easy to define in scripting :
function function_name
{
}
function --> keyword .
function_name---> valid identifier .
Example :
##variables
today=$(date +"%x %r ")
##functions
function todayIS
{
echo $today
}
Output will be : Monday 26 January 2009 10:04:59 PM IST {something like this}
It is simple easy and yet very powerful to use functions(methods) in your code :).
Be careful in selecting the function and variable names , note that it wont conflict with the reserved keywords of the shell like PATH,HOME etc
function function_name
{
}
function --> keyword .
function_name---> valid identifier .
Example :
##variables
today=$(date +"%x %r ")
##functions
function todayIS
{
echo $today
}
Output will be : Monday 26 January 2009 10:04:59 PM IST {something like this}
It is simple easy and yet very powerful to use functions(methods) in your code :).
Be careful in selecting the function and variable names , note that it wont conflict with the reserved keywords of the shell like PATH,HOME etc
Recent blog posts
- watir-webdriver web inspector
- gem list to gemfile
- Packing ruby2.0 on debian.
- Made it into The Guinness Book!
- to_h in ruby 2.0
- Filter elements by pattern jQuery.
- Better HTML password fields for mobile ?
- Grayscale image when user offline
- nth-child CSS pseudo-class Christmas colors
- EventEmitter in nodejs