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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:09:05+00:00 2026-06-03T11:09:05+00:00

I am trying to extract columns from multiple text files(3000 files). The sample of

  • 0

I am trying to extract columns from multiple text files(3000 files). The sample of my text file is shown below.

res          ABS    sum
SER A   1   161.15 138.3 
CYS A   2    66.65  49.6
PRO A   3    21.48  15.8 
ALA A   4    77.68  72.0 
ILE A   5    15.70   9.0
HIS A   6    10.88   5.9

I would like to print
1) resnames(first column) only if the sum(last column) is >25.
2) I would like to store the output in to one file
3) I would like to add a new column to the outputfile with the name of the txt file from where the data was extracted and also need to print the total number of resnames( from all text files only if sum is >25)

I would like to get the following output

SER   AA.txt
CYS   AA.txt
ALA   AA.txt
SER   BB.txt

Total numberof  SER- 2
Total number of ALA- 1
Total number of CYS- 1

How can I get this output with Bash? I tried the following code

for i in  files/*.txt
do
awk 'BEGIN{FS=OFS=" "}{if($5 > 25) print $1,i}'
done

Any suggestions please?

  • 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-03T11:09:07+00:00Added an answer on June 3, 2026 at 11:09 am
    awk '{
        if ($NF ~ /([0-9])+(\.)?([0-9])+/ && $NF > 25) {
            print $1, FILENAME;
            res[$1]++;
        }
    }
    END {
         for (i in res) {
              print "Total number of ", i, "-", res[i];
        }
    }' res.txt
    

    Here’s the output I get for your example:

    SER res.txt
    CYS res.txt
    ALA res.txt
    Total number of  SER - 1
    Total number of  CYS - 1
    Total number of  ALA - 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to extract graph information from a text file and converting it
I'm trying extract the nth + 1 and nth + 3 columns from a
I'm trying to extract the number from a text string and join it to
I am trying to extract numeric data from a database where the columns have
Trying to extract files to a given folder ignoring the path in the zipfile
I'm trying to extract about 72000 SInt32s from the iPhone, but not sure what
I am trying to extract the port from a given in_addr value in windows.
I'm trying to extract column names from a SQLite result set from sqlite_master's sql
I'm trying to get data from file. The file first has three lines of
I have two .csv files containing correlation matrices exported from R. One file contains

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.