I'm trying to do a search and replace using sed and wild cards. The search part seems to be working but the replace is using a string literal instead of regex.
How do I search and then use the found string as part of the replace?
For example if I have strings that end with something like the following:
valueset-nachc-a0-de2
valueset-nachc-b9-de12345
I can find the strings I'm looking for with something like the following:
grep -r "https://nachc-cad.github.io/hiv-cds/resources/hiv-cds/vocabulary/valueset/generated/valueset-nachc-[a-z][0-9]-de[0-9]*"
But if I use the sed below I get the string shown. How do I get the original string + ".json" so the ouput contains the following?
find . -type f -exec sed -i 's/https:\/\/nachc-cad.github.io\/hiv-cds\/resources\/hiv-cds\/vocabulary\/valueset\/generated\/valueset-nachc-[a-z][0-9]-de[0-9]*/https:\/\/nachc-cad.github.io\/hiv-cds\/resources\/hiv-cds\/vocabulary\/valueset\/generated\/valueset-nachc-[a-z][0-9]-de[0-9]*.json/g' {} +
Output:
valueset-nachc-[a-z][0-9]-de[0-9]*.json
Desired output
valueset-nachc-a0-de2.json
valueset-nachc-b9-de12345.json
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.