Hi Folks,
I'm trying to write a simple file sanity check script. I have a directory with dozen CSV files containing id,edname,firstname,lastname,suffix,email.
I like to write a awk script to check if first field contain a number and is not empty. and fields number 3,4 & 6 are not empty and that the file contains 6 fields no more no less than 6, if all of this conditions are true nothing happens but if any of these conditions failed, re-name the file to .bad. Here is what i have done so far.
for f in *.csv;
do
awk -F, '!(NF==6 && $1+0==$1 && $6 == ""){f=1; exit} END{exit f}' "$f" || mv "$f" "$f".bad;
done