We validate some incoming data fields and create validation_error reports which will contain records which do not pass validation. Once files are processed they will all be dropped under one folder.
As seen above, of the 5 files, 3 of them have rejects and 2 were processed fine. I need to prepare a report which looks like:
FILE NAME Status
-------------------------------------
PRSNL_INFO - Processed successfully
SAL_HIKE - Processed successfully
EMPLOYEE - Has error resubmit
DEPARTMENT - Has error resubmit
SALARY - Has error resubmit
Can someone help me how I can go about creating the report?
ls *.txt |
awk 'BEGIN {print "FILE NAME\tStatus\n-------------------------------------"}
{gsub(/_[0-9]*$/, "", $1); OUT[$1]}
/error/ {OUT[$1]++}
END {for (i in OUT) print i, OUT?"- has error":"- success"}
' FS="." OFS="\t"
FILE NAME Status
-------------------------------------
SALARY - has error
DEPARTMENT - has error
EMPLOYEE - has error
PRSNL_INFO - success
SAL_HIKE - success