12. 执行标志(e标志)
最后更新时间 (CST):2023-07-20 06:10:01 +0800
sed 替换标志e
代表执行。 使用e
标志,您可以将模式空间中可用的任何内容作为 shell 命令执行,并且输出将返回到模式空间。
注意:这仅在 GNU Sed
中可用。
执行示例
创建以下文件,其中包含文件名列表及其完整路径。
$ cat files.txt
/etc/passwd
/etc/group
Example1:在每一行前面添加文本 "ls -l"
并打印输出
$ sed 's/^/ls -l /' files.txt
ls -l /etc/passwd
ls -l /etc/group
Example2:在每一行前面添加文本 "ls -l"
并执行
$ sed 's/^/ls -l /e' files.txt
-rw-r--r-- 1 root root 1547 Oct 27 08:11 /etc/passwd
-rw-r--r-- 1 root root 651 Oct 27 08:11 /etc/group
如未另行说明,那么本页面中的内容已根据 知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。内容随着时间推移,可能会过期,会定时更新或移除一些旧的内容。
最后更新时间 (CST):2023-07-20
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"很难理解"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"信息或示例代码不正确"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"没有我需要的信息/示例"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]