The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for April 15th, 2020

sed double expression: match, replace in one line, overwrite file

Posted by jpluimers on 2020/04/15

A while ago, I needed to conditionally replace in files, so I used sed and a regular expression, though usually I dislike those.

However, since the system had a very basic install, there was not much choice.

Luckily back then, my Google foo returned these:

This allowed me to do a double expression (the first matches a pattern, the second performs the actual replacement within the matching lines).

In case my Google foo in the future fails:

## https://robots.thoughtbot.com/sed-102-replace-in-place
## -i causes no backup to be saved, but does in-place replacement
## since we run under git, we can always restore
## combined with a double expression (the first matches, the second executes) this is very powerful
sed -i -e '/#.*AVOID_DAILY_AUTOCOMMITS=.*$/s/^.//' /etc/etckeeper/etckeeper.conf && git diff | more

–jeroen

Posted in *nix, Development, etckeeper, Linux, Power User, RegEx, Software Development | Leave a Comment »

GitHub – JensBorrisholt/GoogleSpeak: This repository demonstrates how to Use Google for implementing Text to Speech. You’ll find both a Delphi version and a C# version

Posted by jpluimers on 2020/04/15

For my link archive, as I will likely need this one day: [WayBackGitHub – JensBorrisholt/GoogleSpeak: This repository demonstrates how to Use Google for implementing Text to Speech. You’ll find both a Delphi version and a C# version

–jeroen

Posted in .NET, C#, Delphi, Development, Software Development | Leave a Comment »