![テキストファイルのデータを置き換える[閉じる]](https://linux33.com/image/97388/%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E3%82%92%E7%BD%AE%E3%81%8D%E6%8F%9B%E3%81%88%E3%82%8B%5B%E9%96%89%E3%81%98%E3%82%8B%5D.png)
ファイルが2つあります。
ファイル1:
world,11
ファイル2:
hello welcome to the ("12345,67")
"(12345,67)"
上記の内容を次のように変更しようとしています。"world,11"
答え1
あなたの投稿によれば、このコードはあなたの問題を解決すると思います。
replacement=`cat replacement.txt`
content=`cat content.txt`
pattern="pattern"
echo "${content//$pattern/$replacement}" # all strings matching will be replaced with $replacement
echo "${content/$pattern/$replacement}" # the first string matching the pattern will be replaced