Emacs, scripting and anything text oriented.

Search/replace groups using sed

Kaushal Modi

This is the most common way of my sed usage:

echo Good morning | sed 's/\(.*\s\+\).*/\1evening/g'

Here are brief notes on that ..

The above script changes Good morning to Good evening. Note that the following characters needed the escape character \:

  • Brackets to create regex groups: \( \)
  • Plus sign to match one or more times: \+
  • Note that the . and * characters don’t need escaping.

If you have written a response to this, enter your response post's URL below.

Or, you can send a "comment" webmention (it's OK if you don't know what that means). When asked about your website on an IndieAuth login screen, simply type https://commentpara.de.

Markdown Support**bold**, _italics_, ~~strikethrough~~, [descr](link), `monospace`, ```LANG\nline1\nline2\n``` (Yep, multi-line code blocks too, with syntax highlighting!), auto-hyperlinking.

Webmentions #