Quantcast
Channel: Count the maximum character length for all the data fields in a simplified csv file and output to txt - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 5

Answer by G-Man for Count the maximum character length for all the data fields in a simplified csv file and output to txt

$
0
0

If I understand your question correctly, this will do what you want:

awk -F, 'NR!=1 { if (max_NF < NF) max_NF = NF;
                 for (i=1; i<=NF; i++) if (max[i] < length($i)) max[i] = length($i) }
         END   { for (i=1; i<=max_NF; i++) printf "%-2d | %d\n", i, max[i] }'

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>