I'm trying to separate Valid and Invalid records in a CSV file based on a number of columns. I went through the below SO question and seems to be doing the same.
Delete row which has more than X columns in a csv
However for my case delimiter is ^H, so tried below approaches.
awk -v FS="\b" 'NF==3' sample.csv >> output.csv
awk -v FS="\\^H" 'NF==3' sample.csv >> output.csv
awk -v FS="\\cH" 'NF==3' sample.csv >> output.csv
awk -v FS="^H" 'NF==3' sample.csv >> output.csv
However, nothing worked for ^H delimiter.
Moreover, in the previous SO question, they are capturing the valid records(to output), I want to capture both and invalid records into two different files.
Sample.csv
timestamp,header2,header3
1^H1val2^H1val3
2^H2val2^H2val3
3^H4^H4val2^H4val3
5^H5val2^H5val3
6^H6val2^H6val3
Valid.csv
timestamp,header2,header3
1^H1val2^H1val3
2^H2val2^H2val3
5^H5val2^H5val3
6^H6val2^H6val3
Invalid.csv
timestamp,header2,header3
3^H4^H4val2^H4val3
Any suggestions please.