I have a number of .py files that contain a line like this:
self._cols = [self.foo.bar.relevant_string.str()]
I need to capitalise the relevant_string, to get this
self._cols = [self.foo.bar.RELEVANT_STRING.str()]
in all ~100 of them.
Is there a way to do this with bash/awk/perl? I tried something like this
perl -pe 's/self.foo.bar./uc($&)/e' *.py
But it capitalised the captured area, not the part after.
With GNU sed:
$ echo 'self._cols = [self.foo.bar.relevant_string.str()]' |
sed -E 's/(self\.foo\.bar\.)([^.]+)/\1\U\2/'
self._cols = [self.foo.bar.RELEVANT_STRING.str()]
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