globalweather:
name: 'globalweather:1.0.0'
我想: sed -i '' "s/^\(*\)name: '$api_name'$/&\n\1\$ref: $1/" $2
,但我發現:
globalweather:
name: 'globalweather:1.0.0'n $ref: globalweather_1.0.0.yaml
我要:
globalweather:
$ref: globalweather_1.0.0.yaml
有人可以幫我解決我失蹤的問題嗎?
的'&'在您的替換字符串被轉換爲「整個匹配的字符串」。然後你將該字符串的一部分添加到它。那是故意的嗎?它似乎不是,根據您的預期輸出。 – ghoti