35. 处理多个文件
在我们之前的所有 sed 示例中,我们仅传递了一个输入文件。 您还可以传递多个输入文件,如下所示。
以下示例在 /etc/passwd 文件中搜索 root 并打印它:
$ sed -n '/root/ p' /etc/passwd
root:x:0:0:root:/root:/bin/bash
以下示例在 /etc/group 中搜索 root 并打印它:
$ sed -n '/root/ p' /etc/group
root:x:0:
在 /etc/passwd 和 /etc/group 文件中搜索 root:
$ sed -n '/root/ p' /etc/passwd /etc/group
root:x:0:0:root:/root:/bin/bash
root:x:0: