テキストファイル内のデータの置き換え

テキストファイル内のデータの置き換え

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

関連情報