pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit da02eddf6e2d679141adfe686e3d5b5a9a11fb25
parent be52e412f06413196a5a827456b710f7f22566bd
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 24 Feb 2022 23:38:07 +0000

delimitless

Diffstat:
Aentry/delimitless.md | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/entry/delimitless.md b/entry/delimitless.md @@ -0,0 +1,24 @@ +If you have used `sed` then you have used the `/` delimiter +``` +sed s/foo/bar/g file +``` + +You will also probably be aware the need to escape any slash in the string you're trying to match, for example matching `f/o/o` would be +``` +sed s/f\/o\/o/b\/a\/r/g file +``` + +What some people may not know is you can use different delimiters to save yourself escaping any occurrence of slash in the string. + +``` +sed s%foo%bar%g file +sed 's|foo|bar|g' file +sed 's foo bar g' file +``` + +Note that some delimiters require quotes. Any occurrence of your chosen delimiter in the string will have to be escaped. + +According to section 4.3 of the `sed` Info document you should be able to use "any single character", giving you a lot of options to chose from in order to avoid all the escaping. To read this section of the Info document incant +``` +info sed -n "regexp addresses" +```