Wednesday, March 23, 2016

Selecting lines before and after search pattern using grep

To select lines before and after a pattern you want to match use grep and options -A and -B.


mpjanic@valkyr:~/REBUTTAL_F1000RESEARCH$ grep rs12896399 DIAGRAMv3.2012DEC17.txt
rs12896399      14      91843416        T       G       1.3E-01 1.03    0.99    1.07    9580    53810
mpjanic@valkyr:~/REBUTTAL_F1000RESEARCH$ grep rs12896399 -A 10 -B 10 DIAGRAMv3.2012DEC17.txt
rs1951351       14      91832947        G       A       7.1E-02 1.04    1.00    1.08    9580    53810
rs4900109       14      91833144        T       G       1.6E-01 1.03    0.99    1.07    9580    53810
rs4904864       14      91834272        G       A       6.6E-02 1.04    1.00    1.08    9580    53810
rs1885193       14      91835107        G       A       3.3E-01 1.02    0.98    1.05    12171   56862
rs12892379      14      91836910        T       C       6.6E-02 1.04    1.00    1.08    9580    53810
rs1957283       14      91837433        A       G       5.9E-01 1.02    0.95    1.09    9580    53810
rs4904866       14      91838256        T       C       1.5E-01 1.03    0.99    1.07    9580    53810
rs7145248       14      91839145        T       C       5.5E-01 1.02    0.96    1.09    9580    53810
rs12434570      14      91840166        T       C       5.6E-01 1.02    0.96    1.09    9580    53810
rs8021744       14      91843048        T       C       5.6E-01 1.02    0.96    1.09    9580    53810
rs12896399      14      91843416        T       G       1.3E-01 1.03    0.99    1.07    9580    53810
rs746588        14      91845133        T       C       5.7E-01 1.02    0.95    1.09    9580    53810
rs11622569      14      91845155        A       T       5.7E-02 1.04    1.00    1.08    9580    53810
rs746586        14      91845720        T       C       1.2E-01 1.03    0.99    1.07    9580    53810
rs1075830       14      91845915        C       A       5.1E-01 1.01    0.98    1.05    12171   56862
rs8018017       14      91846171        C       G       7.2E-01 1.01    0.95    1.07    11223   52455
rs941799        14      91846578        T       C       1.2E-01 1.03    0.99    1.07    9580    53810
rs1885194       14      91847215        C       T       1.2E-01 1.03    0.99    1.07    9580    53810
rs10484035      14      91848310        C       T       2.6E-01 1.02    0.99    1.06    12171   56862
rs17128162      14      91850110        A       G       3.0E-01 1.06    0.95    1.19    3788    20758
rs17184180      14      91850140        A       T       1.2E-01 1.03    0.99    1.07    9580    53810

No comments:

Post a Comment