bash - Find all matched pattern with grep -


in txt1

s01a1p2 s01a1p5 s01a1p4 

in txt2

data/train/wave/s01a1p3.mfc data/train/wave/s01a1p7.mfc data/train/wave/s01a1p8.mfc data/train/wave/s01a1p1.mfc data/train/wave/s01a1p5.mfc data/train/wave/s01a1p6.mfc data/train/wave/s01a1p2.mfc data/train/wave/s01a1p4.mfc 

use grep -f txt1 txt2 , result

data/train/wave/s01a1p4.mfc 

but want result find pattern

data/train/wave/s01a1p5.mfc data/train/wave/s01a1p2.mfc data/train/wave/s01a1p4.mfc 

what can do?

txt1 contains crlf line terminators. try this:

grep -f <(dos2unix <txt1) txt2 

Comments

Popular posts from this blog

Multilayer CSV to filtered excel -

Listboxes in c# -

ios - Why must I define variables twice in the Header file? -