I found a question about, how to remove lines longer then 2048 chars:
How to delete line if longer than XY?
Q: But how can I remove lines shorter then 4 chars? So remove lines that has 1 or 2 or 3 length in a file.
UPDATE: Thanks for the many GOOD answers, but I can only mark one as OK
Best Answer
You could use
sed
. The following would remove lines that are 3 characters long or smaller:In order to save the changes to the file in-place, supply the
-i
option.If your version of
sed
doesn't support extended RE syntax, then you could write the same in BRE:which would work with all
sed
variants.You could also use
awk
:Using
perl
: