The number of characters n a line of text can be a difficult thing to calculate in a given app. If you have data in a text file, you can use awk to view the number of characters in a given line of the file. This is very helpful, for example, if you have code that you’ve put into documentation that exceeds the character maximum and therefore wraps. When going to print, you need to split these lines up.
Here, we’re going to use the awk command to review all lines that exceed 56 characters:
awk 'length($0) > 56' ~/Repo/Chapter1.xml
krypted October 15th, 2013
Posted In: Mac OS X, Mac OS X Server, Mac Security, Unix
awk, length, number of characters per line, splitting code between lines, wrapping