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 7163885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:58:39+00:00 2026-05-28T13:58:39+00:00

Having a large set of files I need to grep through, I’m doing it

  • 0

Having a large set of files I need to grep through, I’m doing it within a bash script like this:

#! /usr/bin/env bash

REX="word"
grep -IP $REX A* >> result &
grep -IP $REX B* >> result &
grep -IP $REX C* >> result &
grep -IP $REX D* >> result &
[..]

How to know when all the processes are finished?

  • 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-05-28T13:58:39+00:00Added an answer on May 28, 2026 at 1:58 pm

    I would go about solving your problem a different way. find can find specific files on your filesystem, and xargs allows you to run commands on given input files. So I would use a command like this:

    find ./ -type f -print0 | xargs -0 -I{} -n1 -P4 grep -IP $REX '{}' >> result
    

    This would search, starting in the current directory (./) for all regular files (-type f), and pass them along to xargs safely in case there are any spaces in the filename (-print0). xargs then, for each command, runs your grep command. -I{} tells xargs that where it sees {} it will insert the filename into the command. Not strictly necessary here, but good practice. -0 goes hand in hand with -print0 from find, and tells it to expect input that way. -P4 tells xargs to run up to 4 processes at the same time, and -n1, as described by the man page, hints to xargs to only use one argument at a time per command.

    There are various tweaks you can make here, whether it’s not wanting to search for all files, or to only go to a certian depth, but this general command should get you started with this kind of task.

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

Sidebar

Related Questions

I am having issues figuring out how to sort a large data set into
I am having issues with including really large files and so have used ini_set('memory_limit',
I would like to perform some arbitrarily expensive work on an arbitrarily large set
I have a PHP application which runs a large set of SQL files. It
I am having a strange problem while uploading large files in PHP. In php.ini,
Quite a few apps support plugins. Are there any downsides to having a large
Having no end of trouble including a large landscape pdf in a portrait .tex
I am having some threading issues with a large app I am working on
I am having an issue with importing a large(60MB) CSV file in MYSQL DB.
We're having an issue on one of our fairly large websites with spam bots.

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.