Grep 在两行上搜索两种不同的图案,并在一行中打印它们?

Grep 在两行上搜索两种不同的图案,并在一行中打印它们?,grep,Grep,我有一个像这样的文件(1),我想要一个像那样的输出(2)。通过“grep-e文件-e索引”,我得到了这个(3)。你知道实现(2)中的结构缺少什么吗 (一) (二) (三) 如果总是每隔一行粘贴一次,粘贴将执行以下操作: grep -e file -e index infile | paste - - file: path/to/file1 index = a file: path/to/file2 index = b file: path/to/file3 index = c ... fil

我有一个像这样的文件(1),我想要一个像那样的输出(2)。通过“grep-e文件-e索引”,我得到了这个(3)。你知道实现(2)中的结构缺少什么吗

(一)

(二)

(三)


如果总是每隔一行粘贴一次,
粘贴将执行以下操作:

grep -e file -e index infile | paste - -
file: path/to/file1 index = a
file: path/to/file2 index = b
file: path/to/file3 index = c
...
file: path/to/file1 
index = a
file: path/to/file2 
index = b
file: path/to/file3 
index = c
...
grep -e file -e index infile | paste - -