Sed

Speaking of regex: sd - a tool to search and displace

With all its peculiarities of syntax, sed leaves a bit to be desired. That’s why I was pleased to find sd, or “Search and Displace”, a tool that does what sed does but with less arcane syntax.

For example:

# prints "Corruption" (W.Barr)
echo "\"Corruption\" by W.Barr" | sd '(.+)\sby\s(.+)' '$1 ($2)'

Or just leave out the \s metacharacter in favour of a literal string:

sd '(.+) by (.+)' '$1 ($2)'

It does all the tricks you’d expect from a sed replacement. For example, named capture groups: