Hello,
I have this awk script that I want to execute by passing parameters through a shell script.
I'm a little confused. This awk script removes duplicates from an input file.
Ok, so I have a .sh file called rem_dups.sh
#!/usr/bin/sh
#---------------------------------------------------------------------
# Program ....... rem_dups.sh
# Function ...... removes duplicates from input file
# Developer ..... script_op2a
# Date .......... November 2 2010
# Parameters .... $1 = Position of Key column in input file (Required)
$2 = Unix Script directory (Required)
# $3 = Input file name of file to remove duplicates from (Required)
awk '{FS="";split($NF,a,""); key=$pos;site=a[3];keysite=key "" site;
if (b[keysite]<=a[4]a[5]) {b[keysite]=a[4]a[5];c[keysite]=$0;}}
END{for (i in b) print c[i]}' $dir $filename
It needs to have 3 variable parameters.
$pos (this value needs to be the awk field like $1 $2 $3 $4 or whatever)
$dir (this needs to specify the directory of the input file
$filename (this is the name of the input file)
I want to execute it from command line like:
rem_dups.sh 1 /home/scriptop/input_file_dups.txt > output_file_no_dups.txt