-2

I stumbled upon this variation of sed today in my company's codebase. Essentially we want to swap out ssh://git@ for https:// for our CI.

I found this syntax pretty strange and have not been able to find documentation for it on google... Could someone link me to some documentation or provide some insight?

I see it written this way, with ^ separating the search and replace strings. This has removed the need for the / separator as well as any escapes. Is this maybe a regex trick?

sed 's^ssh://git@^https://^g' -i terraform.tfvars

It performs the same as this. Which is what I would have written originally. But the one above just seems so much cleaner and more readable.

sed 's/ssh:\/\/git@/https:\/\//g' -i terraform.tfvars

Some insight is greatly appreciated! Thanks in advance.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Kevin Qiu
  • 211
  • 1
  • 3
  • 9

1 Answers1

-1

sed manual:

The / characters may be uniformly replaced by any other single character within any given s command. The / character (or whatever other character is used in its stead) can appear in the regexp or replacement only if it is preceded by a \ character.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • thanks. actually just saw this https://stackoverflow.com/questions/5864146/using-different-delimiters-in-sed-commands-and-range-addresses i was searching for the wrong keywords. "delimiter" is what I should have searched for. – Kevin Qiu Oct 05 '20 at 18:49