Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda