problem in running an awk script
problem in running an awk script
hi everyone,
i am required to write an awk script that can be run from any directory.
this script finds subscription rates for each subscriber at an interval of 10 mins. i want that just by copy pasting the whole script in shell prompt and giving the input arguments, script must work. currenty what i am doing is copying the whole script in a file and making the file executable.
for example
if my file name is test.awk then currently i run it as written below
# test.awk arg1 arg2 arg3
when copy pasting the whole script in shell prompt its not reading the arguments properly. ( i tried reading input arguments with the read command, but that also doesnt work)
my script is
if [ $# -ne 3 ]; then
echo "usage: $0 subscriber_name log_file_name_with_path";
else
awk /$1/ $2 | sort -u -k 2.1,2.8 | awk -f':' '{print $1":"$2":"$3":"$7}'
| awk -f' ' '{print $1,$2,$4}' | awk -f'_000' '(nr == 1) {printf ("1-->%s %s\n",$1,$2)}
(nr > 1) {printf ("0-->%s %s\n1-->%s %s\n",$1,$2,$1,$2)}' | awk 'ors="@" {print}' | awk -f"1-->" '{ for (i = 1; i<=nf;i++) print $i}' | awk -f"0-->" '/0-->/{print $1,$2}' | awk -f'@' '{print $1,$2}' | awk '{if (substr($6,4,2) == substr($2,4,2)) prinrt (""); else {{print $1,$2,"-->",$5,$6,"-->",(($8-$4)*60)/( 1000* (( substr($6,1,2)-substr($2,1,2) ) * 60 + ( substr($6,4,2)-substr($2,4,2) )) ),"k /hr",
( substr($6,4,2)),substr($2,4,2) , substr($6,1,2),substr($2,1,2)}}}'
fi
can anyone suggest how should i read the arguments and run the above script from the shell prompt.
any help will be sincerely appreciated.
thanks in advance
|