The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AWK or KSH : Sort, Group and extract from 3 files Matrix2682 Shell Programming and Scripting 3 08-21-2009 06:05 PM
Need Help to sort text lines tqlam Shell Programming and Scripting 3 01-21-2009 10:32 AM
extract the lines prvnrk Shell Programming and Scripting 2 05-25-2008 07:17 AM
How to sort lines by substring mr_bold Shell Programming and Scripting 3 04-29-2008 10:17 PM
Extract known lines nhatch UNIX for Dummies Questions & Answers 2 09-16-2004 12:59 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-11-2009
genehunter genehunter is offline
Registered User
  
 

Join Date: May 2009
Posts: 17
Need awk to extract lines and sort

Hi,
My data looks like this.

Code:
 CHR                           SNP         BP   A1       TEST    NMISS         OR         STAT            P
   0                 SNP_A-8282315          0    2        ADD     1530      1.074       0.7707       0.4409
   0                 SNP_A-8282315          0    2       COV1     1530  1.771e+04        4.764    1.898e-06
   0                 SNP_A-8282315          0    2       COV2     1530  1.513e+04        4.645    3.402e-06
   0                 SNP_A-8282315          0    2       COV3     1530      14.16        1.306       0.1915
   0                 SNP_A-8282315          0    2       COV4     1530      1.264       0.1139       0.9093
   0                 SNP_A-8282315          0    2       COV5     1530      2.389       0.4268       0.6695
   0                 SNP_A-8338258          0    4        ADD     1528     0.9498      -0.6824        0.495
   0                 SNP_A-8338258          0    4       COV1     1528  1.846e+04        4.777    1.783e-06
   0                 SNP_A-8338258          0    4       COV2     1528  1.374e+04          4.6    4.224e-06
   0                 SNP_A-8338258          0    4       COV3     1528      14.82         1.33       0.1836
   0                 SNP_A-8338258          0    4       COV4     1528      1.251       0.1087       0.9134
   0                 SNP_A-8338258          0    4       COV5     1528      2.431       0.4354       0.6633

.
.
  1. I want to extract only lines with "ADD" in col. 5 (TEST).
  2. I want to sort ascending on Col 9 (P). This column as shown above has both regular and scientific formats.
  3. How can I keep the headers of the file intact in the outfile?
What I tried:

Code:
gawk '{if(NR>1 && $5="ADD") {print $0}}' infile>outfile

Everything in col5 is changed to ADD.

Last edited by genehunter; 10-11-2009 at 02:33 AM.. Reason: spelling ALL to ADD
 

Bookmarks

Tags
awk, sort

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0