The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 09-29-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
Here is one example::
Code:
month_to_num() {
if [ -n "$1" ]
then
t_month=$1
case $t_month in

Jan) return 01;;
Feb) return 02;;
Mar) return 03;;
Apr) return 04;;
May) return 05;;
Jun) return 06;;
Jul) return 07;;
Aug) return 08;;
Sep) return 09;;
Oct) return 10;;
Nov) return 11;;
Dec) return 12;;
*) return 0;;

esac
fi
}
To call a function and store result in a variable see below lines
Code:
month_to_num $time_month
v_month_index=$?
if you call this function with parameter jan,feb,mar....you will store their index value in variable v_month_index.

Last edited by Dhruva; 09-29-2006 at 04:57 AM.. Reason: typo