Skip to main content
1 of 2
Stéphane Chazelas
  • 584.7k
  • 96
  • 1.1k
  • 1.7k

With grep:

grep -E '^[#!]|.{4}'

That is, select lines that either start with # or ! or contain a sequence of 4 characters.

Or with awk:

awk '/^[#!]/ || length >= 4'

Or with sed:

sed -e '/^[#!]/b' -e '/.\{4\}/!d'
Stéphane Chazelas
  • 584.7k
  • 96
  • 1.1k
  • 1.7k