Earlier quoted context omitted.
> The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. I've always used "|" since it's so visually similar, and you always want to quote regular expressions anyway.
Yes, I’ve seen the vertical bar character used for this too. But in my experience the comma character is more commonly used , and my point was that we should all try to use as commonly used syntax as possible. Therefore I encourage everybody to use the comma character as their usual alternative character in order for the world of Sed code to be slightly less confusing.
Using different delimiters in sed (2010)
11–20 of 30 posts
Re: Using different delimiters in sed (2010)
#12The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
Re: Using different delimiters in sed (2010)
#13Re: Using different delimiters in sed (2010)
#14Re: Using different delimiters in sed (2010)
#15s~foo~bar~
I still use / when pointing out typos in PRs, tho :)
s/calulate/calculate/
Re: Using different delimiters in sed (2010)
#16The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
> The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. I've always used "|" since it's so visually similar, and you always want to quote regular expressions anyway.
Re: Using different delimiters in sed (2010)
#17On a related note, I found Bruce Barnett's sed tutorial is one of the best Sed guide out there: http://www.grymoire.com/Unix/Sed.html
Separately, I feel like I could have a full time job submitting PRs to fix the GNU-ism of using `sed -i"" ...` versus the BSD/macOS syntax of `sed -i "" ...`. I don't know which of those two camps broke from the other, but holy hell it _broke_ for sure.
Re: Using different delimiters in sed (2010)
#18This is one of this extremely useful features that a surprisingly large number of users don’t seem to know about.
Re: Using different delimiters in sed (2010)
#19Earlier quoted context omitted.
> The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. I've always used "|" since it's so visually similar, and you always want to quote regular expressions anyway.
Yes, I’ve seen the vertical bar character used for this too. But in my experience the comma character is more commonly used , and my point was that we should all try to use as commonly used syntax as possible. Therefore I encourage everybody to use the comma character as their usual alternative character in order for the world of Sed code to be slightly less confusing.
Arguing that people must use some standard you’ve adopted is a little like saying people should use tabs instead of spaces.
Re: Using different delimiters in sed (2010)
#20I’ve seen so many hilariously bad workarounds for this in old shell scripts from lazy engineers who apparently can’t read a man page and don’t realise the delimiter character is substitutable with more or less any character you like. This is one of this extremely useful features that a surprisingly large number of users don’t seem to know about.