-1
echo "en_Us" | sed "s._./."  # returning en/Us

I recently encounter a sed command like above, I am not 100% sure why, according to "man sed", s command usually comes like

sed "s/regex/regex"

to replace the the matched regex, in this case, it only has one slash, what does that mean ?

sthbuilder
  • 561
  • 1
  • 7
  • 22
  • In short, it is using a different delimiter here, just like /, since we are going to substitute "_" to "/", using "." as delimiter frees as to use escape characters, if using "/" as delimiter, it should be written as echo "en/Us" | sed "s/_/\//" – sthbuilder Oct 12 '18 at 20:40

1 Answers1

0

echo "en_Us" | sed "s._./." is almost equal to echo "en_Us" | sed "s#_#/#" which means it is the for a word before first occurence of "" and substitute with "/". If you want replace all ""s use the "g" (group) as echo "en_Us" | sed "s._./.g"

jagath
  • 238
  • 1
  • 6