Match all lines in file where specific text pattern is less than


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Match all lines in file where specific text pattern is less than
# 1  
Old 12-22-2016
Match all lines in file where specific text pattern is less than

In the below file I am trying to grep or similar, all lines where only AF= is less than 0.4.. Thank you Smilie.

grep
Code:
grep "AF=" ,+ .4 file

file
Code:
12    112036782    .    T    C    34.0248    PASS    AF=0.194286;AO=32;DP=170;FAO=34;FDP=175;FR=.;FRO=141;FSAF=20;FSAR=14;FSRF=57;FSRR=84;FWDB=-0.0842492;FXX=0.0056815;HRUN=2;LEN=1;MLLD=83.7705;OALT=C;OID=.;OMAPALT=C;OPOS=112036782;OREF=T;PB=0.5;PBP=1;QD=0.77771;RBI=0.128679;REFB=-0.0310314;REVB=-0.0972646;RO=137;SAF=20;SAR=12;SRF=55;SRR=82;SSEN=0;SSEP=0;SSSB=0.280873;STB=0.645079;STBP=0.067;TYPE=snp;VARB=0.090833;ANN=ATXN2    GT:GQ:DP:FDP:RO:FRO:AO:FAO:AF:SAR:SAF:SRF:SRR:FSAR:FSAF:FSRF:FSRR    0/1:34:170:175:137:141:32:34:0.194286:12:20:55:82:14:20:57:84
12    112036795    .    T    A    34.0248    PASS    AF=0.45121;AO=32;DP=170;FAO=34;FDP=175;FR=.;FRO=141;FSAF=20;FSAR=14;FSRF=57;FSRR=84;FWDB=-0.0842492;FXX=0.0056815;HRUN=2;LEN=1;MLLD=83.7705;OALT=C;OID=.;OMAPALT=C;OPOS=112036782;OREF=T;PB=0.5;PBP=1;QD=0.77771;RBI=0.128679;REFB=-0.0310314;REVB=-0.0972646;RO=137;SAF=20;SAR=12;SRF=55;SRR=82;SSEN=0;SSEP=0;SSSB=0.280873;STB=0.645079;STBP=0.067;TYPE=snp;VARB=0.090833;ANN=ATXN2    GT:GQ:DP:FDP:RO:FRO:AO:FAO:AF:SAR:SAF:SRF:SRR:FSAR:FSAF:FSRF:FSRR    0/1:34:170:175:137:141:32:34:0.194286:12:20:55:82:14:20:57:84

desired output
Code:
12    112036782    .    T    C    34.0248    PASS     AF=0.194286;AO=32;DP=170;FAO=34;FDP=175;FR=.;FRO=141;FSAF=20;FSAR=14;FSRF=57;FSRR=84;FWDB=-0.0842492;FXX=0.0056815;HRUN=2;LEN=1;MLLD=83.7705;OALT=C;OID=.;OMAPALT=C;OPOS=112036782;OREF=T;PB=0.5;PBP=1;QD=0.77771;RBI=0.128679;REFB=-0.0310314;REVB=-0.0972646;RO=137;SAF=20;SAR=12;SRF=55;SRR=82;SSEN=0;SSEP=0;SSSB=0.280873;STB=0.645079;STBP=0.067;TYPE=snp;VARB=0.090833;ANN=ATXN2     GT:GQ:DP:FDP:RO:FRO:AO:FAO:AF:SAR:SAF:SRF:SRR:FSAR:FSAF:FSRF:FSRR     0/1:34:170:175:137:141:32:34:0.194286:12:20:55:82:14:20:57:84

# 2  
Old 12-22-2016
making some assumptions - YMMV...
Code:
awk -F'(AF=)|(;)' '$2>0.4' myFile

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 12-22-2016
awk
Code:
awk -FS=" |;|=" '$2 < 0.4' file

grep
Code:
grep "AF=0.[0-3]" file


Last edited by looney; 12-22-2016 at 02:13 PM..
This User Gave Thanks to looney For This Post:
# 4  
Old 12-27-2016
Thank you both and happy holidays Smilie.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. UNIX for Beginners Questions & Answers

Match pattern only between certain lines in entire file

Hello, I have input that looks like this: * 0 -1 103 0 0 m. 7 LineNr 23 ClauseNr 1: 1: 1: 304: 0 0 SentenceNr 13 TxtType: Q Pargr: 2.1 ClType:MSyn PS004,006 ZBX= 0 1 1 0 7 -1 -1 3 2 3 2 -1 1 1 -1 -1 -1 -1 0 501 0 PS004,006 ZBX ... (2 Replies)
Discussion started by: jvoot
2 Replies

3. Shell Programming and Scripting

Match text from file 1 to file 2 and return specific text

I hope this makes sense and is possible. I am trying to match $1 of panel_genes.txt with $3 of RefSeqGene.txt and when a match is found the value in $6 of RefSeqGene.txt Example: ACTA2 is $1 of panel_genes.txt ACTA2 NM_001613.2 ACTA2 NM_001141945.1 awk 'FNR==NR {... (4 Replies)
Discussion started by: cmccabe
4 Replies

4. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

5. Shell Programming and Scripting

Printing next two lines from a file after grepping a specific pattern

Hi I have a file like # vi require.txt 1,BANK,Read blocks that cycle. yellow Read blocks. 2,ACCOUNT,Finished Red Finished . 3,LOAN, pipe white pipe 4,PROFIT,Resolve. black Resolve Am using like cat require.txt | grep -w ACCOUNTThe output I get is (8 Replies)
Discussion started by: Priya Amaresh
8 Replies

6. Shell Programming and Scripting

Help with ksh-to read ip file & append lines to another file based on pattern match

Hi, I need help with this- input.txt : L B white X Y white A B brown M Y black Read this input file and if 3rd column is "white", then add specific lines to another file insert.txt. If 3rd column is brown, add different set of lines to insert.txt, and so on. For example, the given... (6 Replies)
Discussion started by: prashob123
6 Replies

7. Shell Programming and Scripting

fetch last line no form file which is match with specific pattern by grep command

Hi i have a file which have a pattern like this Nov 10 session closed Nov 10 Nov 9 08:14:27 EST5EDT 2010 on tty . Nov 10 Oct 19 02:14:21 EST5EDT 2010 on pts/tk . Nov 10 afrtetryytr Nov 10 session closed Nov 10 Nov 10 03:21:04 EST5EDT 2010 Dec 8 Nov 10 05:03:02 EST5EDT 2010 ... (13 Replies)
Discussion started by: Himanshu_soni
13 Replies

8. Shell Programming and Scripting

deleting lines in a file that match a pattern without opening it

In Unix, how do I delete lines in a file that match a particular pattern without opening it. File contents are foo line1 misc whatever foo line 2 i want to delete all lines that have the pattern "foo" without opening the file. File should eventually contain misc whatever (1 Reply)
Discussion started by: osbourneric
1 Replies

9. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

10. Shell Programming and Scripting

Merge two file data together based on specific pattern match

My input: File_1: 2000_t g1110.b1 abb.1 2001_t g1111.b1 abb.2 abb.2 g1112.b1 abb.3 2002_t . . File_2: 2000_t Ali england 135 abb.1 Zoe british 150 2001_t Ali england 305 g1111.b1 Lucy russia 126 (6 Replies)
Discussion started by: patrick87
6 Replies
Login or Register to Ask a Question