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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:28:10+00:00 2026-06-02T17:28:10+00:00

I am trying to design an awk command to select lines with a value

  • 0

I am trying to design an awk command to select lines with a value column 2 that is in the range of values defined by pairing specific columns of a line together. It has application in calling single nucleotide polymorphisms that are not within 50 nucleotides of exon boundries. The file looks like this:

ID  X   start   end start   end start   end start   end  
Fal1825_c6  802 2   62  62  239 239 362 362 934  
Fal1821_c2  152 1   19  22  159 159 263 264 398  
Fal18279_c7 41  1   177 177 598                 
Fal18376_c3 367 1   251 251 421                 
Fal18748_c2 601 1   152 152 489 489 499 499 677  
Fal18748_c2 500 1   152 152 489 489 499 499 677  
Fal18792_c3 750 1   234 234 459 459 762 762 83  
Fal19487_c2 89  1   177 177 270 270 409 411 459  

I want to only print lines where the value of second column falls in the range (”start” + 50) and (“end” – 50), for any “start” and “end” pairing on that line (pairings only made from “start” and “end” columns next to each other), i.e. between ($3+50 and $4-50) or ($5+50 and $6-50) or ($7+50 and $8-50), and so on, considering all the pairs of start-end columns for the component.

The output would look like:

ID  X   start   end start   end start   end start   end  
Fal1825_c6  802 2   62  62  239 239 362 362 934  
Fal18376_c3 367 1   251 251 421             
Fal18748_c2 601 1   152 152 489 489 499 499 677  
Fal19487_c2 89  1   177 177 270 270 409 411 459  

My attempted command looked like this

awk '{a=3; b=4; while ($a > 0) do {if ($2 > ($a + 50) && $2 < ($b + 50)){print $0} else {a+2, b+2} }'

Thank you

  • 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-02T17:28:16+00:00Added an answer on June 2, 2026 at 5:28 pm

    Try:

    awk '{
    for (i = 3; i <= NF; i += 2)
      if ($2 > $i+50 && $2 < $(i+1)-50) { print; next } 
    }' FILE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to design a code where one guess a number. I defined the
I'm trying to design an entity model for an application that uses ASP.Net membership
I am trying to design a layout so that I can change the views
I'm trying to design a font selection tool where a user can select one
I'm trying to design a homepage for an MVC site that has two different
I'm trying to design a data model that denotes one user being the friend
I'm trying to design some bookmarklets right now, that connect back to a server
I am trying to design a feature in my application for the iPhone that
I'm trying to design a class that needs to dynamically allocate some memory.. I
I'm trying to design a data-structure around a stack that blocks until the stack

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.