Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:09:37+00:00 2026-06-05T20:09:37+00:00

I am trying to do a search in one directory containing a large number

  • 0

I am trying to do a search in one directory containing a large number of html files, to find those files that contain the exact values on the same line. This should work:

grep -iwc 'word1' -sl | xargs grep -iwc 'word2' -s

But that only works on one file at a time. I tried something like this:

find . -iname '*html' | xargs grep -iwc 'word1' -sl | xargs grep -iwc 'word2' -s

But that seems to display files containing any of the two values, so even those that are not on the same line.

The output should only be the file names and the number of occurrences like:

file.html:2

If it possible to group those 2 greps? Or another way to do this search?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:09:38+00:00Added an answer on June 5, 2026 at 8:09 pm

    An extended regex may help. Something like this perhaps?

    find . -iname '*html' | xargs egrep -iwl '(word1.*word2|word2.*word1)'
    

    Since you only have two words you’re looking for, it’s not too hard to list off all the ways to order them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to search through many documents and find all instances where an html
I am trying to process a large number of text files. These text files
I'm trying to find the simplest way to query Active Directory, in one of
I have a number of log files in a directory. I am trying to
I'am trying to write simple script that will get files name from one folder
I am trying to search for information in one table (DATABASE_FAV_EQUIP_TABLE) based on a
I am trying to search for files which matches following expression with sed [a-zA-Z0-9]{1,10}\s{1,5}\
I'm trying to think of the most efficient way to search a directory full
I am working on building a search-engine friendly CMS. I know that perhaps one
I am trying to find a file in a root directory and it's sub-directories.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.