by ariabuckles on 8/12/19, 6:33 PM with 0 comments
So I built a small wrapper around String.prototype.replace to give the syntax and power of javascript regular expressions (and, optionally, javascript functions):
https://github.com/ariabuckles/jsed
Or to install:
npm install -g @ariabuckles/jsed
Some examples:You can use it pretty similarly to `sed`:
echo "this is a test" | jsed '\w+' 'word:$&'
> word:this word:is word:a word:test
Or you can use it more like javascript when needed: echo "1 2 3 4" | jsed '/\d+/g' '(num) => num%2 == 0 ? "even" : "odd"'