-4

I've just encountered this sed expression and could not figure out exactly what it means. I've performed a google search previously. I'd appreciate any help. What does the initial # and the final ## mean?

sed 's#/text##'
paolov
  • 2,139
  • 1
  • 34
  • 43

1 Answers1

2

This replace "/text" into null "", try below it gives blank

echo /text| sed 's#/text##'

Initial # is sed delimited for replace and middle # is seperator between first string to be replace, and Last # is last delimiter for sed

its same as regex/replace sed command

sandeep
  • 152
  • 5
  • Initial # is sed delimited for replace and middle # is seperator between first string (to be replace) and the string to be replace with, and Last # is last delimiter for sed – sandeep Jul 21 '15 at 06:35
  • 1
    It could be written: `sed -e 's/\/text//'` and would mean the same thing. Using the `#` as a delimiter instead of `/` avoids the use of backslashes, which is usually a good idea. – Jonathan Leffler Jul 21 '15 at 06:37
  • oh. ok. thanks. So / and # are the same type of delimiters? – paolov Jul 21 '15 at 06:37
  • 2
    Roughly, yes. The first character after the `s` is the delimiter. Conventionally, that's a slash, but you can use any character as long as you're consistent. In some contexts, a control character such as control-A can be effective; it doesn't often occur in valid text. – Jonathan Leffler Jul 21 '15 at 06:38