我有一个sed命令用于将一行插入shell脚本。我插入的脚本的名称在每个env中都有所不同,我试图这样做。如果我提供这些值,但是当我需要在大量环境中重复此操作时,我需要它从这些值中获取这些值一个json文件。任何想法如何我可以实现这一目标?从json文件中替换sed变量值
语法 - >sed -i '1 a if ! [ipaddress = <value> && OSTYPE = linux]; then exit(1); endif' qa-<envname>-vm1.sh
sed -i '1 a if ! [ipaddress = 0.0.0.0 && OSTYPE = linux]; then exit(1); endif' qa-QAF-vm1.sh
插入
if ! [ipaddress = 0.0.0.0 && OSTYPE = linux]; then exit(1); endif
文件qa-QAF-vm1.sh
在第一行之后。
任何想法如何从json文件中获取ipaddress value
和envname
列出这些值?
的[UNIX命令行JSON分析器?](http://stackoverflow.com/questions/3858671/unix-command-line-json-parser) – Kev