how to pass argument from command prompt
Hi
when I am running the script below,it performs on whatever logfile u type ,i.e, ./scriptname logfilename But how do I convert it into a function and then call it from another script.I mean how do I prompt the user to enter a logname and then capture the name in the function and when calling this function from another script how do I pass the parameter. please help and thankyou so much in advance!!! my script looks like: awk ' { if (index ( $0, ". . exporting table") >0 || index ($0, ". . exporting partition") >0) #searches for the pattern in string { if ($4 != "partition"){ #$4 is either table or a partition i=$6; #$6 is the number of rows stored in variable i here if (table_flag ==0 && table_name ==temp_table_name){ # checking the flag printf table_name > "logcountOP"; printf " " > "logcountOP"; print j > "logcountOP"; } table_name = $5; #$5 has the name of the table from which the rows have been imported temp_table_name = table_name; table_flag =1; #setting the flag to 1 } if ($4 == "partition") { i=i+$6; #summing up the rows in partitioned tables printf("value of i in first: %d\n",i); j=i; table_flag=0; #setting flag to 0 } if (table_flag !=0 && $6 !=""){ printf table_name >> "logcountOP"; printf " " >> "logcountOP"; print i >> "logcountOP"; } } } ' < $1 |
If the script you typed above is /usr/bin/myScript, then you should just be able to use:
Code:
#!/bin/bash All the best, |
Seeing as this is simply an awk script in a bash wrapper, just get rid of bash altogether and ask for log name in the BEGIN:
Code:
#!/usr/bin/awk -f |
Thank uoy so much!!!it works.
|
All times are GMT -5. The time now is 12:06 AM. |