shell count number of columns

Shell
awk '{print NF}' filename | sort -nu | tail -n 1
Source

Also in Shell: