Hi All,
First time post. New to AWK. How can I alter this script to prevent the PID from printing until the FT1 and possibly the PR1 has executed? Right now the data from the PID prints and its associated FT1 data prints on the follwing line. I'm always one step behind with the FT1 and PR1 data. Any help would be appreciated.
awk '
BEGIN {
FS = "|"
printf "%8s%8s%17s%9s%8s%9s%7s\n",
"Account", "Name", "Svc Date", "T code", "HCPCS", "Modif", "Qty"
printf " -------- ---------- --------
------ ----- -----" " ---\n"
}
/^PID\|/ {
Acct = $19
Name = $6
}
/^FT1\|/ {
{printf "%9s %.10s %9s %8s %5s %7s
%7s\n", Acct, Name, SvcDate, Tcode, HCPCS, Modif, Qty }
SvcDate = $5
Tcode = $8
Qty = $11
HCPCS = ""
Modif = ""
}
/^PR1\|/ {
if ($7 == "M"
{Modif = $4}
else
{HCPCS = substr($4,1,5)}
}
END {
{printf "%9s %.10s %9s %8s %5s %7s %7s\n",
Acct, Name, SvcDate, Tcode, HCPCS, Modif, Qty }
}'
First time post. New to AWK. How can I alter this script to prevent the PID from printing until the FT1 and possibly the PR1 has executed? Right now the data from the PID prints and its associated FT1 data prints on the follwing line. I'm always one step behind with the FT1 and PR1 data. Any help would be appreciated.
awk '
BEGIN {
FS = "|"
printf "%8s%8s%17s%9s%8s%9s%7s\n",
"Account", "Name", "Svc Date", "T code", "HCPCS", "Modif", "Qty"
printf " -------- ---------- --------
------ ----- -----" " ---\n"
}
/^PID\|/ {
Acct = $19
Name = $6
}
/^FT1\|/ {
{printf "%9s %.10s %9s %8s %5s %7s
%7s\n", Acct, Name, SvcDate, Tcode, HCPCS, Modif, Qty }
SvcDate = $5
Tcode = $8
Qty = $11
HCPCS = ""
Modif = ""
}
/^PR1\|/ {
if ($7 == "M"
{Modif = $4}
else
{HCPCS = substr($4,1,5)}
}
END {
{printf "%9s %.10s %9s %8s %5s %7s %7s\n",
Acct, Name, SvcDate, Tcode, HCPCS, Modif, Qty }
}'