如何替换$ {}在文本文件中的占位符? [英] How to replace ${} placeholders in a text file?

查看:743
本文介绍了如何替换$ {}在文本文件中的占位符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要管模板文件的输出到MySQL,有像 $变量文件{DBNAME} 穿插。什么是命令行实用程序来替换这些实例和转储输出到标准输出?

I want to pipe the output of a "template" file into MySQL, the file having variables like ${dbName} interspersed. What is the command line utility to replace these instances and dump the output to standard output?

推荐答案

桑达

由于template.txt:

Given template.txt:


The number is ${i}
The word is ${word}

我们不得不说:

sed -e "s/\${i}/1/" -e "s/\${word}/dog/" template.txt

感谢乔纳森·莱弗勒的小费传递多个 -e 参数相同 SED 调用。

这篇关于如何替换$ {}在文本文件中的占位符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆