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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:55:51+00:00 2026-06-06T04:55:51+00:00

So I have about 1000 files that are multiple columns, but I’m only interested

  • 0

So I have about 1000 files that are multiple columns, but I’m only interested in some stats of two of those columns. If $4 was something like a star’s spectral class (ie a unique value) and $5 in each of these files was a result, like seen, unseen, unknown, etc, is there a recommended way to grep or awk out the stats like so across the 1000 or so files so I get something like:

Type O, #verified, #not-verified, #property-j, ...
Type B, ...
Type A, ...
.
.
.
Type i,

Where, in each file, you’d see something like:

$1, $2, $3, Spectral Type, Result
foo, foo, foo, A, verified
foo, foo, foo, G, verified
foo, foo, foo, A, unknown
foo, foo, foo, F, verified
foo, foo, foo, G, verified
foo, foo, foo, K, verified
foo, foo, foo, K, seen
  • 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-06T04:55:54+00:00Added an answer on June 6, 2026 at 4:55 am

    If your question is: “How do I generate output of the form “Type $4, $5″ where $4 and $5 are the 4th and 5th columns of the input, respectively?” one solution is:

    for i in list of input file; do
      awk '{print "Type "$4, $5}' $i > $i.result
    done
    

    This gives the output that it seems you want, but relies on the all columns not containing whitespace. If there may be whitespace, you can do:

     awk '{printf( "Type %s, %s", $4, $5 )}' FS=, $i > $i.result
    

    but you may want to trim the extra whitespace that this will generate. Please note that although in the example I have hardcoded the list of input files to be the 4 files names “list”, “of”, “input”, and “file”, I do not expect you to type the names in. Instead, you should generate them in some fashion, and I’m merely demonstrated one (of many!) methods of iterating over a set of files. It seems that the heart of this question is the portion dealing with awk, and not the iteration.

    A second reading of the question indicates that you have exactly one row per input file and you want to summarize the results in a single file. In that case, just do:

    cat list of all files | awk '{print "Type "$4, $5}'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one folder with about 1000 files and I want to group them
I have a DataGridView in a Winforms app that has about 1000 rows (unbound)
I have a simple Parallel.Foreach loop that has about 1000 rows in the DataTable,
I have a table with about 1000 records and 2000 columns. What I want
I have this problem: I have a collection of small files that are about
I have a table (parts) that has 2 columns in it, 1000 or so
I'm using XCode4, and I have about 1000 audio files included in my application.
I have about 1000 folders that I want to extract a single file from
I have big (about 1000 pages) pdf file. Is some Java API/Library to extract
I have a list containing about 1000 file names to search under a directory

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.