Aug. 29, 2011, 12:50 p.m.

Finding lines in a text file with differing lengths

I recently had to find out whether a very large text file had any lines where the length (character count) of each line differed, as they needed to be identical. This will help:

cat file.txt | awk '{gsub(/[ \t]+$/,""); print length($0)}' | sort -u