regex - How to find lines using patterns in a file in UNIX -


i trying use .txt file around 5000 patterns (spaced line) search through file of 18000 lines matches. far i've tried every form of grep , awk can find on internet , it's still not working, stumped.

here's text each file.

pattern.txt

rs2622590 rs925489 rs2798334 rs6801957 rs6801957 rs13137008 rs3807989 rs10850409 rs2798269 rs549182 

there's no spaces or anything.

file.txt

snpid hg18chr bp a1 a2 zscore pval ceumaf rs3131972       1       742584        g       0.289   0.7726  . rs3131969       1       744045        g       0.393   0.6946  . rs3131967       1       744197  t       c       0.443   0.658   . rs1048488       1       750775  t       c       -0.289  0.7726  . rs12562034      1       758311        g       -1.552  0.1207  0.09167 rs4040617       1       769185        g       -0.414  0.6786  0.875 rs4970383       1       828418        c       0.214   0.8303  . rs4475691       1       836671  t       c       -0.604  0.5461  . rs1806509       1       843817        c       -0.262  0.7933  . 

the file.txt downloaded directly med directory.

i'm pretty new unix amazing!

sorry edit: have tried every single thing guys recommending , result blank. maybe missing syntax issue or in text files?

p.p.s know there matches doing individual greps works. i'll move question unix.stackexchange. answers guys i'll try them out.

issue solved: using dos carriages. didn't know before thank answered. future users having issue, here solution worked:

dos2unix *

awk 'nr==fnr{p[$0];next} $1 in p' patterns.txt file.txt > output.txt

idk if it's want or not, print every line file.txt first field equals string patterns.txt:

awk 'nr==fnr{p[$0];next} $1 in p' patterns.txt file.txt 

if not want, tell want. if want doesn't produce output expect 1 or both of files contains control characters courtesy of being created in windows run dos2unix or similar on them both first.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -