shell字符串替換命令

替換文件中的字符串
sed -i "s/oldstring/newstring/g" `grep oldstring -rl /tmp/mydir`

shell腳本中替換字符串

#!/bin/bash

str='hello oldstring!'
dist="${str/oldstring/newstring}"

echo $dist

 

參考:https://blog.csdn.net/q322625/article/details/88888305

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章