shell脚本:更换内容 [英] shell script : replace contents
本文介绍了shell脚本:更换内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下信息文件
文件名: VersionInfo.properties
Installed Version:13.7.0-2
Previous Version:13.6.0-12
文件名: rollback.sh
#!/bin/bash
uninstall_rpm ClientInfrastructure $version
我怎样才能获得价值为VersionInfo.properties文件变量的 $版本从 previous版本。 $版本应具有价值的 13.6.0-12
How can I get the value into variable $version from Previous Version of VersionInfo.properties file. $version should have the value 13.6.0-12
推荐答案
SED
解决方案:
version=$(sed -n 's/Previous Version:\(.*\)/\1/p' VersionInfo.properties)
要在脚本中使用它,你可以这样做:
To use it in a script you can do:
#!/bin/bash
version=$(sed -n 's/Previous Version:\(.*\)/\1/p' VersionInfo.properties)
uninstall_rpm ClientInfrastructure "$version"
如果这是你在你的脚本有,那么你基本上可以做它在命令行上。
If that is all you have in your script then you can basically do it on the command line.
uninstall_rpm ClientInfrastructure "$(sed -n 's/Previous Version:\(.*\)/\1/p' VersionInfo.properties)"
这篇关于shell脚本:更换内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文