A flag -ifor sed will edit the file in place. For XXX and YYY you should use something like:
sed -i 's/USER_NAME/userName/g'
etc.
. , "USER_NAME" "userName" . Perl script:
sub convert {
my $r = lc $_[0];
$r =~ s/_(.)/\U$1\E/g;
return $r;
}
while (<>) {
s/\${([A-Z_]+)}/\${@{[convert $1]}}/g;
print;
}
:
perl -i convert.pl inputfile.txt
:
$ cat inputfile.txt
Hello ${USER_NAME}, you live at ${HOME_ADDRESS}. It is now ${TIME}
$ perl -i convert.pl inputfile.txt
$ cat inputfile.txt
Hello ${userName}, you live at ${homeAddress}. It is now ${time}