我有兩個文件
文件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