テキストファイルのデータを置き換える[閉じる]

テキストファイルのデータを置き換える[閉じる]

ファイルが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

おすすめ記事