Say I have a large file with many rows and many columns. I\'d like to find out how many rows and columns I have using bash.
A very simple way to count the columns of the first line in pure bash (no awk, perl, or other languages):
read -r line < $input_file ncols=`echo $line | wc -w`
This will work if your data are formatted appropriately.