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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:02:00+00:00 2026-06-16T03:02:00+00:00

I would like to extract lines of a file where specific columns have a

  • 0

I would like to extract lines of a file where specific columns have a value <0.05.

For example if $2 or $4 or $6 has a value <0.05 then I want to send that line to a new file.
I do not want any lines that have a value >0.05 in any of these columns

cat File_1.txt 
S_003   P_003   S_006   P_006   S_008   P_008
74.9    0.006   59.6    0.061   72.2    0.002
96.2    0.003   89.4    0.001   106.9   0.000
105.8   0.003   72.6    0.003   86.7    0.002
45.8    0.726   38.5    0.981   43.9    0.800
50.7    0.305   47.8    0.314   46.6    0.615
49.9    0.366   50.4    0.165   48.2    0.392
42.5    0.920   43.7    0.698   40.3    0.970
46.3    0.684   42.9    0.760   47.7    0.438
192.4   0.001   312.8   0.001   274.3   0.001

I tried this using awk, but it would only work doing it a very long way.

awk ' $2<=0.05' file_1.txt > file_2.txt
awk ' $4<=0.05' file_2.txt > file_3.txt

etc, and achieved the desired result

96.2    0.003   89.4    0.001   106.9   0.000
105.8   0.003   72.6    0.003   86.7    0.002
192.4   0.001   312.8   0.001   274.3   0.001

but my file is 198 columns and 57000 lines

I also tried piping the awk commands together with no luck. it only searches $2

awk ' $2<=0.05 || $4=<0.05' File_1.txt > File_2.txt

74.9    0.006   59.6    0.051   72.2    0.002
96.2    0.003   89.4    0.001   106.9   0.000
105.8   0.003   72.6    0.003   86.7    0.002
192.4   0.001   312.8   0.001   274.3   0.001

I’m pretty new at this and would appreciate any advice on how to achieve this using awk

Thanks

Sam

  • 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-16T03:02:01+00:00Added an answer on June 16, 2026 at 3:02 am

    Perhaps this is what you’re looking for. It will search every even numbered column and check that each of these columns contain numbers smaller than ‘0.05’:

    awk 'NF>1 { for(i=2;i<=NF;i+=2) if ($i>0.05) next }1' File_1.txt
    

    Results:

    96.2    0.003   89.4    0.001   106.9   0.000
    105.8   0.003   72.6    0.003   86.7    0.002
    192.4   0.001   312.8   0.001   274.3   0.001
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to extract some lines from a text file, I have started
I have an ASCII log file with some content I would like to extract.
I have a big text file and I would like to extract only numbers
The following lines are present in the file. I would like to extract multiple
I would like to extract chains from pdb files. I have a file named
I would like to extract and construct some strings after identifying a substring that
I would like to extract a value or its inverse from database. I would
I have the next string /1234/somename and I would like to extract the somename
I have a log file that looks like the following: 2010-05-12 12:23:45 Some sort
I have a folder that contains text files. I need to extract lines that

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.