Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!