Column name Problem

Hi,

I have a Comma seperated file of 20 columns, 2 of the column has names as "Name, Last " and "Name, First " . I want to count the no of Columns. to see if we recieved all the 20 columns or not.
when i am using the below code its giving me an error. Please Help

`head -1 Detail_$FILE_NAME | awk -F "," '{print NF }'`

Thanks

Don't use backticks (`) if you want to print the result of the command.

Regards

what errors are you getting?

also please keep in mind the "Name, First" will be counted as two fields by awk when you use "," as FS.

I want it to be counted as one....
From that code i am getting the count of Columns as 22 where as it should be 20. I want to know if there is any way that we can consider the value with in the double codes as one field

it is 22 because first part of the first field and the second part of the last field is treated as two fields by awk.

what is the separator between the fileds? is it a tab ( \t )?
if yes, then set the FS to "\t".

I have the column names like this
Type,Number,Number,DOB,"Name, Last","Name, First",Gender,SubscriberID,Sub_Sequence Number,Member Number,Corporate Entity Code

I want to change the Column names as

Type,Number,Number,DOB,Name Last,Name First,Gender,SubscriberID,Sub_Sequence Number,Member Number,Corporate Entity Code

Can someone please help

I believe there is a similar question here:

Or perhaps you could change your field separator to something other than comma (like pipe)?

But i have 2 fields with double quotes.....

Try this:

awk -F"\"" '{for(i=2;i<NF;i+=2){gsub(",","",$i)}}1' OFS=

Regards

I got it....Below is the code

sed -e ':a' -e 's/\("[^"][^"]*\),\([^"][^"]*"\)/\1|\2/;ta' $FILE_NAME > Output_$FILE_NAME