You are on page 1of 8

Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.

html

bash

MarkerName Allele1 Allele2 Freq1 Fre


qSE P-value Chr Pos
rs2326918 a g 0.8510 0.0001 0.5
255 6 130881784
rs2439906 c g 0.0316 0.0039 0.8
997 10 6870306
rs10760160 a c 0.5289 0.0191 0.8
107 9 123043147
rs977590 a g 0.9354 0.0023 0.8
757 7 34415290
rs17278013 t g 0.7498 0.0067 0.3
595 14 24783304
rs7852050 a g 0.8814 0.0006 0.7
671 9 9151167
rs7323548 a g 0.0432 0.0032 0.4
555 13 112320879

1 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

rs12364336 a g 0.8720 0.0015 0.4


542 11 99515186
rs12562373 a g 0.7548 0.0020 0.6
151 1 164634379

Chr
Pos

@UCLALibrary

Home
About
Academicons
Twitter
GitHub
LinkedIn
Orcid
Resume
awk "{print NF}" < pos_cut.txt | uniq

NF
uniq

uniq

awk '{print $1 $2}' pos_cut.txt

rs11058339t

2 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

rs7338610t
rs882601t
rs13290449t
rs2941056a
rs10444526a
rs12190167a
rs1125337a
rs7911101a
rs13053206c
rs697690t
rs12447687t
rs2402752t
@UCLALibrary rs12042911a
...
Home
About
Academicons
Twitter
GitHub
LinkedIn
Orcid
Resume

awk '/2410626/' pos_cut.txt

rs4853805 a t 0.2107 0.0029 0.4


229 2 2410626

3 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

Chr
Pos

@UCLALibrary
if
Home
About
Academicons
Twitter awk '{ if ($7 == 6) { print } }' pos_cu
t1-5.txt | head
GitHub
LinkedIn
Orcid rs2326918 a g 0.8510 0.0001 0.5
255 6 130881784
Resume rs16877977 a g 0.1302 0.0048 0.0
5945 6 16494324
rs7763812 a t 0.9815 0.0008 0.0
5328 6 104042808
rs222555 c g 0.3720 0.0051 0.7
756 6 95272331
rs9450727 t c 0.6193 0.0106 0.0
8575 6 88293919
rs12200899 t c 0.7683 0.0075 0.7
118 6 66215503
rs990018 t c 0.0201 0.0000 0.6
292 6 68825590
rs1344178 a c 0.6250 0.0016 0.7
234 6 118804141
rs12529570 c g 0.1987 0.0148 0.2
66 6 110283483
rs3130560 t g 0.2706 0.0242 0.2
365 6 31205432

if
($7 == 6)
$7

$7

4 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

$6 ==

| head

@UCLALibrary

Home
Pos
About >=
Academicons
Twitter
GitHub
LinkedIn awk '{ if($8 >= 11000000) { print }}' p
os_cut.txt | head
Orcid
Resume
MarkerName Allele1 Allele2 Freq1 Fre
qSE P-value Chr Pos
rs2326918 a g 0.8510 0.0001 0.5
255 6 130881784
rs10760160 a c 0.5289 0.0191 0.8
107 9 123043147
rs977590 a g 0.9354 0.0023 0.8
757 7 34415290
rs17278013 t g 0.7498 0.0067 0.3
595 14 24783304
rs7323548 a g 0.0432 0.0032 0.4
555 13 112320879
rs12364336 a g 0.8720 0.0015 0.4
542 11 99515186
rs12562373 a g 0.7548 0.0020 0.6
151 1 164634379
rs17706069 a t 0.8055 0.0537 0.9
93 16 27095047
rs17035887 a g 0.0588 0.0072 0.6
673 2 46983448

if

5 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

@UCLALibrary

Home
awk -F "\t" '{ if(($7 == 6) && ($8 >= 1
About 1000000)) { print } }' pos_cut.txt | ta
il
Academicons
Twitter
GitHub rs9320690 a g 0.5342 0.0041 0.9
136 6 119812605
LinkedIn
rs483727 t c 0.2512 0.0052 0.1
Orcid 624 6 81681348
rs754997 t g 0.8192 0.0091 0.6
Resume 605 6 133635869
rs2073214 t c 0.1465 0.0007 0.1
076 6 144123302
rs12195885 a c 0.0224 0.0000 0.9
662 6 23600679
rs6924121 t c 0.6988 0.0031 0.4
138 6 165249220
rs11961870 a c 0.2470 0.0094 0.9
404 6 143943842
rs9476984 c g 0.0711 0.0014 0.9
935 6 16036569
rs9382099 t c 0.1443 0.0043 0.7
554 6 52328752
rs2504065 a g 0.4974 0.0009 0.3
366 6 152136860

&&
|| !

$8

awk -F "\t" '{ if(($7 == 6) && ($8 >= 1

6 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

1000000 && $8 <= 25000000)) { print } }


' pos_cut.txt

rs16877977 a g 0.1302 0.0048 0.0


5945 6 16494324
rs7767788 t c 0.6144 0.0042 0.3
234 6 14098813
rs12523811 a c 0.5216 0.0055 0.2
504 6 17941531
rs12199382 a g 0.4045 0.0113 0.7
@UCLALibrary 856 6 22435109
rs9465281 c g 0.0719 0.0105 0.1
794 6 19326722
Home
rs13196524 t c 0.9426 0.0209 0.8
About 672 6 22356754
rs12195885 a c 0.0224 0.0000 0.9
Academicons 662 6 23600679
Twitter rs9476984 c g 0.0711 0.0014 0.9
935 6 16036569
GitHub
LinkedIn
Orcid
Resume

awk -f
source-file

7 of 8 2/9/2018 10:14 AM
Using AWK to Filter Rows · Tim Dennis http://www.tim-dennis.com/data/tech/2016/08/09/using-awk-filter-rows.html

@UCLALibrary

Home
About
Academicons
Twitter
GitHub
LinkedIn
Orcid
Resume

8 of 8 2/9/2018 10:14 AM

You might also like