25Jun/090
Count the number of characters (or columns) in a file
Sometimes you want to count the number of characters or columns in a file.
1 | awk 'length>max{max=length}END{print max}' filename.txt |
For extraordinarily long or wide data sets you may want to consider the following:
1 | head -n 10 | awk 'length>max{max=length}END{print max}' |
OR
1 | tail -n 10 | awk 'length>max{max=length}END{print max}' |