file1
다음 정보가 포함된 파일이 있습니다.
TCONS_00000011 XLOC_000003 - u q1:MSTRG.39|MSTRG.39.9|4|0.000000|0.000000|0.000000|7468
TCONS_00000012 XLOC_000004 - u q1:MSTRG.41|MSTRG.41.1|2|0.000000|0.000000|0.000000|1270
TCONS_00000013 XLOC_000003 - u q1:MSTRG.39|MSTRG.39.10|2|0.000000|0.000000|0.000000|6835
TCONS_00000014 XLOC_000003 - u q1:MSTRG.39|MSTRG.39.11|2|0.000000|0.000000|0.000000|880
TCONS_00000015 XLOC_000003 - u q1:MSTRG.39|MSTRG.39.12|3|0.000000|0.000000|0.000000|377
TCONS_00000016 XLOC_000005 - u q1:MSTRG.2|MSTRG.2.1|1|0.000000|0.000000|0.000000|709
TCONS_00000017 XLOC_000006 - u q1:MSTRG.4|MSTRG.4.1|1|0.000000|0.000000|0.000000|343
TCONS_00000018 XLOC_000007 - u q1:MSTRG.40|MSTRG.40.1|7|0.000000|0.000000|0.000000|12112
TCONS_00000019 XLOC_000007 - u q1:MSTRG.40|MSTRG.40.2|2|0.000000|0.000000|0.000000|310
TCONS_00000020 XLOC_000007 - u q1:MSTRG.40|MSTRG.40.3|3|0.000000|0.000000|0.000000|538
TCONS_00000021 XLOC_000008 - u q1:MSTRG.42|MSTRG.42.1|9|0.000000|0.000000|0.000000|6331
TCONS_00000022 XLOC_000008 - u q1:MSTRG.42|MSTRG.42.2|5|0.000000|0.000000|0.000000|1311
TCONS_00000023 XLOC_000008 - u q1:MSTRG.42|MSTRG.42.3|5|0.000000|0.000000|0.000000|923
TCONS_00000024 XLOC_000008 - u q1:MSTRG.42|MSTRG.42.4|2|0.000000|0.000000|0.000000|455
TCONS_00000025 XLOC_000009 - u q1:MSTRG.7|MSTRG.7.1|1|0.000000|0.000000|0.000000|232
TCONS_00000026 XLOC_000010 - u q1:MSTRG.6|MSTRG.6.1|1|0.000000|0.000000|0.000000|483
TCONS_00000027 XLOC_000011 - u q1:MSTRG.12|MSTRG.12.1|2|0.000000|0.000000|0.000000|2489
TCONS_00000028 XLOC_000012 - u q1:MSTRG.14|MSTRG.14.1|1|0.000000|0.000000|0.000000|7604
TCONS_00000029 XLOC_000013 - u q1:MSTRG.55|MSTRG.55.1|4|0.000000|0.000000|0.000000|1511
다음 과 file2
같이:
XLOC_000005
XLOC_000007
XLOC_000009
XLOC_000010
XLOC_000012
에서 오는 정보가 두 번째 열과 일치 file2
하는지 여부 에 따라 에서 file1
모든 정보를 추출하고 싶습니다 file1
. 출력은 다음과 같아야 합니다.
TCONS_00000016 XLOC_000005 - u q1:MSTRG.2|MSTRG.2.1|1|0.000000|0.000000|0.000000|709
TCONS_00000018 XLOC_000007 - u q1:MSTRG.40|MSTRG.40.1|7|0.000000|0.000000|0.000000|12112
TCONS_00000019 XLOC_000007 - u q1:MSTRG.40|MSTRG.40.2|2|0.000000|0.000000|0.000000|310
TCONS_00000020 XLOC_000007 - u q1:MSTRG.40|MSTRG.40.3|3|0.000000|0.000000|0.000000|538
TCONS_00000025 XLOC_000009 - u q1:MSTRG.7|MSTRG.7.1|1|0.000000|0.000000|0.000000|232
TCONS_00000026 XLOC_000010 - u q1:MSTRG.6|MSTRG.6.1|1|0.000000|0.000000|0.000000|483
TCONS_00000028 XLOC_000012 - u q1:MSTRG.14|MSTRG.14.1|1|0.000000|0.000000|0.000000|7604
이 Linux를 어떻게 수행합니까?
답변1
이것은 아마도 당신이 원하는 것입니다:
awk 'NR==FNR{a[$1]; next} $2 in a' file2 file1