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

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -