Quote:
Originally Posted by
aigles
Try with nawk or gawk instead of awk
Jean-Pierre.
i have tried on this script
nawk -v NamesList="customerCode,PrimaryAddress,Model_Handle,usid" \
'
function output_datas( i, out) {
if (Valid) {
for (i=1; i<=NamesCount; i++) {
out = (out ? out OFS : "") Values[i];
}
print out;
}
}
function reset_datas( i) {
Valid = "";
for (i=1; i<=NamesCount; i++)
Values[i] = "";
}
BEGIN {
NamesCount = split(NamesList, Names, ",");
Header = "";
for (i=1; i<=NamesCount; i++) {
Indexes[tolower(Names[i])] = i;
Header = (Header ? Header OFS : "") Names[i];
}
print Header;
}
/^Id/ {
output_datas();
reset_datas();
next;
}
{
name = tolower($2);
value = $3;
if (name in Indexes) {
Values[Indexes[name]] = value;
Valid++;
}
}
END {
output_datas();
}
' list_of_customer_number
the out put was in wrong fromat
customerCode PrimaryAddress Model_Handle usid
57.217.41.201 0x11322800
57.215.49.14 0x113fa800
57.219.48.83 0x11395800
57.219.48.47 0x11389000
57.219.48.140 0x11384000
57.0.144.159 0x1131f000
57.217.46.212 0x11303489
also i need to put the output in a file.. how to fix above ?
regards