files
$cat file 1 Index1 annotation1 abcd Index2 annotation2 efgh Index3 annotation3 hijk Index4 annotation4 lmno Index5 annotation5 pqrs …
$cat file2 Index1 Index3 Index5
我想得到的是第1号档案中的线路清单,以及随后检索的每条线。
Index1 annotation1 abcd Index3 annotation3 hijk Index5 annotation5 pqrs
My current solution is to use grep and its file flag
grep -A 1 --file="file2" file1 | awk !/--/
但是,我很想知道,是否有更明智的解决办法。 目前的解决办法需要很长的时间,因为档案是巨大的。