![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Return an array of strings from user defined function in awk | user_prady | Shell Programming and Scripting | 2 | 12-04-2007 12:03 AM |
| awk printf for user defined variables | jabberwocky | Shell Programming and Scripting | 1 | 10-02-2007 09:07 AM |
| User defined service | markdrury | UNIX for Dummies Questions & Answers | 1 | 02-09-2006 01:08 AM |
| User defined signal 1 | nitesh_raj | AIX | 0 | 01-29-2005 02:20 AM |
| Nawk user-defined function | NewbieGirl | Shell Programming and Scripting | 1 | 06-20-2003 11:51 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
Quote:
Thank you very much Mr. Porter.. Will try now shortly... Regards, user_prady |
|
||||
|
Quote:
Code:
I_plt=/tmp/I_out.plt$$
Q_plt=/tmp/Q_out.plt$$
plot(){
echo "#!/usr/local/bin/gnuplot -persist" > $1_plt
echo "plot \"$1_indat.txt\" " >> $1_plt
}
plot I
cat $I_plt
plot Q
cat $Q_plt
I tried that one it works fine inside double quotes but when I want to replace "$1"in the output redirection it wont works. user_prady shall I have to put single qute or double quote for that $1 or > $"$1_plt" . Last edited by user_prady; 11-16-2007 at 12:03 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|