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

201
Visualizações
How can I find files that end in ".html", but don't have ".bin" anywhere in the filename?

I have the following types of file names:

  1. One ends with .html:

    l_scheduling_suite.temp.html
    
  2. Another type ends with .html but has .bin in its name:

    l_scheduling_suite.temp.bin.html
    
  3. And a third ends with .bin:

    l_scheduling_suite.temp.bin
    

The filename is arbitrary. It won't necessarily always have a temp before .html or .bin. I need to find all the files that comply with only the first format. I am piping to grep using the following regex to find the files, but I am not able to make it work:

"(?=(\.html)$) (?=(?!\.bin))"

How should I use grep or find to get the right list of files?

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

0

Try this:

find -type f | grep -P '^.*(?<!\.bin)\.html$'

This uses a negative lookbehind. Basically it means, get all names that end with .html, but then just make sure that .bin doesn't come before it.

over 4 years ago · Santiago Trujillo Relatório

0

Use a Simple Glob Pattern

You're vastly overcomplicating the problem. All you need (based on your posted corpus) is:

find . -name \*.temp.html

This will find all files that end with .temp.html. Your other examples wouldn't match because *.bin.html and *.temp.bin have no overlap with this glob pattern.

Use Negated Globs

If your corpus was poorly chosen, and you're actually trying to match all files that end in .html but that don't include .bin anywhere in the name, then you can just use the find utility with a negated glob without resorting to regular expressions, pipes, extended shell globs, or other contortions. For example:

find . -name '*.html' -not -name '*.bin*'
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