I'm refactoring some code across lots of files, and am trying to do a search and replace using sed
on a Mac.
The goal is to go from this:
fooActions: typeof fooActionCreators
to this:
fooActions: Partial<typeof fooActionCreators>
I've gotten it to mostly work using this sed expression:
ag -l "Actions: typeof " | xargs sed -i "" -e "s/Actions: typeof \(\w*\)/Actions: Partial<typeof \1>/g"
Basically using ag
to find the list of file names containing a matching string, then use xargs
to pass those as input to my sed
expression.
The output I get though looks like this:
fooActions: Partial<typeof >fooActionCreators
I can't figure out why my capture group is being placed at then end instead of where I have it in the replace clause.