Solutions Log by Dan Reiland

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}'
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.