Use awk To Display Lines That Exceed A Number of Characters

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

Comments are closed.