Skip to main content
added 63 characters in body
Source Link
Stéphane Chazelas
  • 584.7k
  • 96
  • 1.1k
  • 1.7k

With grep:

< file.in grep -E '^[#!]|.{4}' > file.out

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

Or with awk:

< file.in awk '/^[#!]/ || length >= 4' > file.out

Or with sed:

< file.in sed -e '/^[#!]/b' -e '/.\{4\}/!d' > file.out

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'

With grep:

< file.in grep -E '^[#!]|.{4}' > file.out

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

Or with awk:

< file.in awk '/^[#!]/ || length >= 4' > file.out

Or with sed:

< file.in sed -e '/^[#!]/b' -e '/.\{4\}/!d' > file.out
Source Link
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'