I am using below logic to validate whether i am expecting the correct data from source,if not logic should give which column has error.i am running below logic in linux
awk -F, '
NR==1{next}
{f=" "}
$1!~/^[0-9. -]{0,5}$|^$/{f=f?f" emp_id-error":"emp_id-error"}
$4!~/^[0-9 -]{0,6}$|^$/{f=f?f" tot_amt-error":"tot_amt-error"}
$5!~/^[0-9" "]{0,4}-[0-9" "]{0,2}-[0-9" "]{0,2} [0-9" "]{0,2}:[0-9" "]{0,2}:[0-9" "]{0,2}{0,29}$|^$/{f=f?f" current_time-error":"current_time-error"}
{print f,$0}
' /home/vivek/Documents/datagentest_10.txt
datagentest_10.txt
file
emp_id,emp_name,market_name,tot_amt,current_time
1,Brandon Buckner,avil,526,2015-08-11 00:47:00
11,ram,avil,633,2015-08-11 00:47:00
11,raffm,avil,633,2015-08-11 00:47:00
11,ramrtt,avil,633,2015-08-11 00:47:00
data looks good but i am getting error for all columns and for all rows.please help me.
error message:
emp_id-error tot_amt-error current_time-error 1,Brandon Buckner,avil,526,2015-08-11 00:47:00