In a source code file, I need to change all the instances like
foo_bar('param')
to become
booch['param']=$param
Here, param is a token and it can vary. It can be anything.
i.e., in a file,
all the
foo_bar('xxx')
have to become
booch['xxx']=$xxx
and,
all the
foo_bar('yyy')
have to become
booch['yyy']=$yyy
and so on. I'm trying to do it by writing a shell script and using sed. But couldnt figure out how to do it. Hope my query is understandable. Thanks
sed "s/foo_bar('\([^']*\)')/booch['\1']=$\1/g" infile > outfile
$ echo "foo_bar('xxx')" | sed "s/foo_bar('\(.*\)')/booch['\1']=$\1/"
booch['xxx']=$xxx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With