shell count number of columns 1

shell count number of columns

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

Here is what the above code is Doing:
1. awk ‘{print NF}’ filename: prints the number of fields in each line of the file.
2. sort -nu: sorts the output of the previous command and removes duplicates.
3. tail -n 1: prints the last line of the output, which should be the highest number of fields.

Similar Posts