Hi,
I have a comma (,) delimited file, in which few fields are enclosed with in double quotes " ". I have to print the records in the file which donot have expected number of field with the line number.
File1
====
name,desgnation,doj,project #header#
asath,se,15-06-2010,asc,"india,mumbai"
rif,sse,12-05-2010,asc
si,tl,01-12-2009,asc
mthr,"ase,trans",15-09-2010
sdu,ase,15-09-2010,bench
Here lets say me expected number of field is 4. And in the above input, record 2 has 5 fields and record 5 as 2 fields. I have to print the two records with line number.
Expected output
File1_fldmismatchrcrds
==================
2 asath,se,15-06-2010,asc,"india,mumbai"
5 mthr,"ase,trans",15-09-2010
I tried the below code
awk -F "," '{gsub(/"[^"]*"/,x);if (NF != '4'){print NR,$0}}' File1
This gives me the output as
2 asath,se,15-06-2010,asc,
5 mthr,,15-09-2010
```[/b]
Can someone please help on this issue?
:wall: