数码产品

linux 中进行字符串的匹配替换

第一种方式

sed -i "s/替换的目标/替换之后的内容/g" 要进行替换的文件。

 

第二种方式:

echo "要进行替换的字符串"  |  sed -e "s/替换的目标/替换之后的内容/g"

 

第三种方式:


firstStr=$1
secondStr=$2
replacestr=$3

echo "======firststr is ====== ${firstStr}"

echo "======secondstr is ======= ${secondStr}"

echo "${firstStr/$secondStr/$replacestr}"

 

posted @ 2020-03-26 16:21  Hackerman  阅读(1834)  评论(0编辑  收藏  举报
数码产品