How do I count the number of columns in a file in Unix?

How do I count the number of columns in a file in Unix?
Answer
Just quit right after the first line. Unless you’re using spaces in there, you should be able to use
| wc -w on the first line. wc is “Word Count”, which simply counts the words in the input file. If you send only one line, it’ll tell you the amount of columns.
 

Tìm kiếm

Back
Top