extract lines that match a list of words in another file
8
votes
3
answers
15162
views
I have file 1 which have those lines:
ATM 1434.972183
BMPR2 10762.78192
BMPR2 10762.78192
BMPR2 1469.14535
BMPR2 1469.14535
BMPR2 1738.479639
BMS1 4907.841667
BMS1 4907.841667
BMS1 880.4532628
BMS1 880.4532628
BMS1P17 1249.75
BMS1P17 1249.75
BMS1P17 1606.821429
BMS1P17 1606.821429
BMS1P17 1666.333333
BMS1P17 1666.333333
BMS1P17 2108.460317
BMS1P17 2108
And file 2 have a list of words:
ATM
BMS1
So, the output will be like this:
ATM 1434.972183
BMS1 4907.841667
BMS1 4907.841667
BMS1 880.4532628
BMS1 880.4532628
I know it's really a duplicate question, but I tried all types of
grep
and sed
and awk
, maybe it will works with you guys with this tiny example
but I have a very huge file > 1M lines
and all previous way doesn't help
it return part of the lines that containing those words although there are other words in file 2
that matches the lines from file 1
Asked by LamaMo
(223 rep)
Jul 25, 2018, 06:59 PM
Last activity: Aug 6, 2025, 07:52 PM
Last activity: Aug 6, 2025, 07:52 PM