bash – 如何替换文本文件中的${}占位符?
发布时间:2020-12-15 16:45:20 所属栏目:安全 来源:网络整理
导读:我想管道输出一个“模板”文件到MySQL,该文件具有变量如$ {dbName}散置。什么是命令行实用程序来替换这些实例并将输出转储到标准输出? Sed! 给定template.txt: The number is ${i}The word is ${word} 我们只需要说: sed -e "s/${i}/1/" -e "s/${word
我想管道输出一个“模板”文件到MySQL,该文件具有变量如$ {dbName}散置。什么是命令行实用程序来替换这些实例并将输出转储到标准输出?
Sed!
给定template.txt: The number is ${i} The word is ${word} 我们只需要说: sed -e "s/${i}/1/" -e "s/${word}/dog/" template.txt 感谢Jonathan Leffler提示将多个-e参数传递给同一个sed调用。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |