How to count number of columns in CSV file using bash shell - LinuxConfig.org

Probably the easiest way to count number of columns in CSV file using bash shell is simply count number of commas in a single row. In the following example the content of the file myfile.csv is: $ cat myfile.csv 1,2,3,4,5 a,b,c,d,e a,b,c,d,e
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-count-number-of-columns-in-csv-file-using-bash-shell