I love `sed`, but specifying in-place replacement across linux/mac is challenging, and I find both the regular expression options hard to remember the exact syntax for.<p>So I built a small wrapper around String.prototype.replace to give the syntax and power of javascript regular expressions (and, optionally, javascript functions):<p>https://github.com/ariabuckles/jsed<p>Or to install:<p><pre><code> npm install -g @ariabuckles/jsed
</code></pre>
Some examples:<p>You can use it pretty similarly to `sed`:<p><pre><code> echo "this is a test" | jsed '\w+' 'word:$&'
> word:this word:is word:a word:test
</code></pre>
Or you can use it more like javascript when needed:<p><pre><code> echo "1 2 3 4" | jsed '/\d+/g' '(num) => num%2 == 0 ? "even" : "odd"'</code></pre>