|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extracting rows from a text file if the value of a column falls between a certain range
Hi, I have a file that looks like the following: Code:
10 100080417 rs7915867 ILMN_1343295 12 6243093 7747537 10 100190264 rs2296431 ILMN_1343295 12 6643093 6647537 10 100719451 SNP94374 ILMN_1343295 12 6688093 7599537 10 101217090 rs6584276 ILMN_1343295 12 6688093 6947537 I want to extract all the lines where the value in column 2 is within +/- 1,000,000 the range given by the values in columns 6 and 7 (i.e. either between the values in columns 6 and 7, or less than 1,000,000 smaller from the value in column 6, or less than 1,000,000 greater from the value in column 7) Thanks! |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
If I understood correctly, you could try this: Code:
awk '$2>($6-1000000) || $2<($7+1000000)' While thinking twice, I came to the conclusion that the above should better read Code:
awk '$2>($6-1000000) && $2<($7+1000000)' Last edited by user8; 02-09-2013 at 06:46 PM.. Reason: && rather than || |
| The Following User Says Thank You to user8 For This Useful Post: | ||
evelibertine (02-08-2013) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extracting rows from a text file based on the values of two columns (given ranges) | evelibertine | UNIX for Dummies Questions & Answers | 1 | 10-19-2012 11:36 AM |
| Extracting rows from a space delimited text file based on the values of a column | evelibertine | UNIX for Dummies Questions & Answers | 2 | 02-17-2012 01:58 PM |
| Extracting rows from a text file based on numerical values of a column | evelibertine | UNIX for Dummies Questions & Answers | 1 | 10-25-2011 01:13 PM |
| Extracting rows from a text file based on the first column | evelibertine | UNIX for Dummies Questions & Answers | 1 | 09-19-2011 08:15 PM |
| Extracting rows from a text file based on the first column | evelibertine | UNIX for Dummies Questions & Answers | 1 | 08-17-2011 05:53 PM |
|
|