Skip to main content
added 145 characters in body
Source Link
devnull
  • 10.8k
  • 2
  • 43
  • 50

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

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:

sed '/^.\{,3\}$/d' filename 

which would work with all sed variants.


You could also use awk:

awk 'length($0)>3' filename 

Using perl:

perl -lne 'length()>3 && print' filename 

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

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:

sed '/^.\{,3\}$/d' filename 

which would work with all sed variants.

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

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:

sed '/^.\{,3\}$/d' filename 

which would work with all sed variants.


You could also use awk:

awk 'length($0)>3' filename 

Using perl:

perl -lne 'length()>3 && print' filename 
added 139 characters in body
Source Link
devnull
  • 10.8k
  • 2
  • 43
  • 50

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

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:

sed '/^.\{,3\}$/d' filename 

which would work with all sed variants.

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

In order to save the changes to the file in-place, supply the -i option.

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

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:

sed '/^.\{,3\}$/d' filename 

which would work with all sed variants.

Source Link
devnull
  • 10.8k
  • 2
  • 43
  • 50

You could use sed. The following would remove lines that are 3 characters long or smaller:

sed -r '/^.{,3}$/d' filename 

In order to save the changes to the file in-place, supply the -i option.