Link to home
Start Free TrialLog in
Avatar of sunny82
sunny82

asked on

Calculating no. of columns in a flat file

Hi,

I want to find out the no. of columns in a flat file. If it is "," delimited, I am using
awk -F\\, '{print NF;exit}' filename.txt
which is giving me correct results.

But the delimiter can be either comma or pipe delimited. How can I make that provision in Unix?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunny82
sunny82

ASKER

Many thanks, it worked great!