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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:59:21+00:00 2026-06-14T18:59:21+00:00

basic Awk question, but I can’t seem to find an answer anywhere: I have

  • 0

basic Awk question, but I can’t seem to find an answer anywhere:

I have a folder of 50000 txt files, from which I would like to run AWK searches on a subset. I’ve saved the filenames I want to limit the search to in a separate document. This would greatly speed up the search, which at the moment looks like this:

awk -F "searchTerm" '{print NF-1}' data/output/*>> output.txt

Many thanks

  • 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-14T18:59:22+00:00Added an answer on June 14, 2026 at 6:59 pm

    Suppose that your file containing the subset that you want to search is called subset.txt and its content has this format (each file on a separate line):

    file1.txt
    file2.txt
    file3.txt
    ...
    fileN.txt
    

    Then this will do the trick:

    awk -F "searchTerm" '{print NF-1}' $(<subset.txt) >> output.txt
    

    Explanation:

    • $(<subset.txt) will supply the subset list of files to awk as input. (See Jonathan Leffler’s comment below)

    I should also point out that -F "searchTerm" is actually setting the Field Separator (limiter used by awk on each line) to searchTerm. If you want to print the Number of Fields – 1 on each line that contains “searchTerm”, do:

    awk '/searchTerm/ {print NF-1}' $(cat subset.txt) >> output.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basic question, but I can't figure it out...I have a label with an accelerator
basic question, but I'm unsure. Not looking for code as an answer. I want
Basic question - I have a UIWebView with a pdf document loaded. How can
This is such a basic question in awk . But I am facing issues
Basic powershell question here - I have two computers in the c:\temp\servers.txt file and
Basic question but I've searched and can't quite get this nailed - how can
Basic question here - I have many lines of code that look something like:
Basic C# syntax question: So I have this class public class BrandQuery<T> : Query<T>
Basic question.. had to ask. Any help will be appreciated. Q: Why can't I
Basic question so I feel dumb but..., Whats the proper syntax below in the

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.