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

208
Visualizações
How to find which line is missing in another file

on Linux box I have one file as below A.txt

1
2
3
4

Second file as below B.txt

1
2
3
6

I want to know what is inside A.txt but not in B.txt i.e. it should print value 4

I want to do that on Linux.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

awk 'NR==FNR{a[$0]=1;next}!a[$0]' B A

didn't test, give it a try

over 4 years ago · Santiago Trujillo Relatório

0

Use comm if the files are sorted as your sample input shows:

$ comm -23 A.txt B.txt
4

If the files are unsorted, see @Kent's awk solution.

over 4 years ago · Santiago Trujillo Relatório

0

You can also do this using grep by combining the -v (show non-matching lines), -x (match whole lines) and -f (read patterns from file) options:

$ grep -v -x -f B.txt A.txt
4

This does not depend on the order of the files - it will remove any lines from A that match a line in B.

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