3 ms·
Problem: Given a CSV file, we want to know the number of columns just by analyzing its header. $ head -n 1 data.csv | awk -F ',' '{print NF}' Or spare a pr
by dredmorbius 8y ago
Problem: Given a CSV file, we want to know the number of columns just by analyzing its header.
$ head -n 1 data.csv | awk -F ',' '{print NF}'
Or spare a process:
awk -F ',' 'NR <= 1 {print NF; quit}' data.csv
One of numerous weak points to this article.