使用sed从变量中删除模式 [英] Delete pattern from a variable with sed
本文介绍了使用sed从变量中删除模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个脚本,该脚本具有一个名为 PRODUCT_VERSION
的变量.该版本带有一个点(例如 6.0
).我需要删除点并将结果保存到另一个变量中.
I am working with a script that has a variable called PRODUCT_VERSION
.
The version comes with a dot (for example 6.0
).
I need to remove the dot and save the result in another variable.
到目前为止,我来了,但是它不能正常工作
So far I come with this, but it does not work correctly
PRD_VER=$(sed "s/$PRODUCT_VERSION/\.//g")
推荐答案
$ PRODUCT_VERSION=6.0
$ PRD_VER=${PRODUCT_VERSION/.}
$ echo $PRD_VER
60
这篇关于使用sed从变量中删除模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文