I have a script that takes several CSV files from a folder and puts them together in a gzip file with one field extracted from the file name :
awk -F";" 'BEGIN { OFS = FS }
FNR == 1 { match(FILENAME, "([0-9]{8})", a); JOBID = a[1]; print $0, JOBID }
FNR > 1 { print $0, JOBID }' Event_*txt | gzip > agzipfile.gz
My goal is to use NF
to check if the line contains 5 fields and if not print this line to stderr or to another file.
But I didn't understand or find a proper way of doing this.
Is it possible and how ?
PS: I'm using GNU awk