Hi
I want to print a header and report with the fields selected. The issue is that my programm does not print the values.
my initial script
awk -v fields="1,2,3,4,5" '
BEGIN{
#header array
n[1]="ID"
...
n[103]="lastField"
l=split(fields,ARR,",")
for ( i=1;i<=l;i++){
printf i==l? n[ARR] : n[ARR]";" ## print header
var == "" ? var="$"ARR : var=var"\";\"$"ARR ## build associative array
}
print"\n"
print var
}{
val[var]++ ##Associative array
}END{
for ( i in val ) print i";"val ## print associative array
} ' file.txt
output
ID;MSISDN;VERSION_ID;NODE_ID;MMSC_ENTITY
$1";"$2";"$3";"$4";"$5;1 # does not print the values
Any suggest
Thanks a lot
Malpa