Suppress Lines Too Short
Wed, 2006-05-17 15:57
From Bash, core tools, and GNU tools (and I mean a default install like Ubuntu Breezy), what is a way to suppress the display of lines that are not of a fixed length? For instance, if the line is 24 chars, it's fine. But if it's less than 24 chars, that's a line I want to supress when catting a file.
For now, I'm going to do this with PHP.










awk. You will want to use something along the lines of
if [ length($0) > 24 ] then { print $0 }
(the above is probably not correct, I never seriously used awk, and last time was four years ago, however IIRC $0 is the whole line and I'm sure there is a length function.
You could also use the regular expression .........................* (25 dots and an asterisk) with either awk or sed, but that's just silly.Â
Actually, the regular expression is not such a bad idea after all. You could use
cat file | grep ........................ > file2
(24 dots)Â
.{24}
is shorter
Good point. Never needed to count anything in regexes...