Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to find any lines in a file that exceed 79 characters?

share|improve this question

1 Answer 1

up vote 17 down vote accepted

In order of decreasing speed according to my tests:

grep '.\{80\}' file

perl -nle 'print if length$_>79' file

awk 'length($0)>79' file

sed -n '/.\{80\}/p' file
share|improve this answer
What do you mean by "efficient"? –  bladezzz Jul 12 '12 at 18:30
I think manatwork means typing efficiency. awk can come closer if you drop ($0), which is implicit anyway ;). –  Thor Jul 12 '12 at 18:36
Oh, thanks for the clarification. I don't particularly care about speed though. –  bladezzz Jul 12 '12 at 18:37
BTW, if you anchor the regexp to the beginning of the line with ^, it's slightly faster: e.g. grep '^.\{80\}' file. –  cas Jul 29 '12 at 9:32
The perl solution does not account for variable size encoding such as UTF-8, unlike all the other solutions. –  BatchyX Jan 30 '13 at 16:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.