The UNIX and Linux Forums  

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 -->
  #1 (permalink)  
Old 11-15-2007
user_prady user_prady is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 163
Smile need help with User Defined Function

Dear Friends,

I need a help regarding User defined function in shell script.

My problem is as follows:

my_func.sh

Code:
my_funcI(){
        grep 'mystring' I.dat
}
my_funcQ(){
       grep 'mystring' Q.dat
}
myfuncI
myfuncQ

But As both the function has same function only the name of the input file is changing I want to pass the file name to the function and merge them to one function. I want something like below ,

Code:
my_func(FILE){
      grep 'mystring' ${FIlE}.dat
}
my_func(I)
my_func(Q)

Please help me wiht a code..

Thanks in advance
user_prady