Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
Delete single character rows in a text file

I have a text file with about 8 million rows in it. I need to remove all the rows with a single character in them. For example

This is 
the 
text file 
I 
wrote

I want to remove the entire line that has the pronoun "I" on it. Bonus points to the one who can do this on the linux command line.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Here is a try:

awk 'length>1' file

and if you do not want to delete blank lines (with zero characters)

awk 'length!=1' file

And if you have spaces on the lines (that you do not want to count as characters):

awk '{gsub(/[[:space:]]/,"")}length!=1' file
over 4 years ago · Santiago Trujillo Denunciar

0

sed can do that as well:

sed '/^.$/d' inputFile

To store the output in a new file:

sed '/^.$/d' inputFile > outputFile

or for in-file editing:

sed -i '/^.$/d' inputFile
over 4 years ago · Santiago Trujillo Denunciar

0

All you need is:

grep '..' file

unless you want to keep empty lines as well in which case it'd be:

grep -v '^.$' file
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda