Reputation: 1344
This sed works, to replace the value for Java home in a shell script:
sed -i 's#^JAVA_HOME=.*$#JAVA_HOME="/usr/lib/jvm/java-1.7.0-oracle.x86_64"#' /apps/tempbsu.sh
but now I am trying to use/invoke that sed
from inside a Perl app, using qx()
:
qx(sed -i 's#^JAVA_HOME=.*$#JAVA_HOME="/usr/lib/jvm/java-1.7.0-oracle.x86_64"#' /apps/tempbsu.sh);
and when I do that, I am getting an error:
sed: -e expression #1, char 58: unterminated `s' command
From checking, I gather that error is happening because the sed is missing the last delimiter, but it seems like it is correct, i.e.:
sed -i 's#.....#.......#' /apps/tempbssu.sh
Can someone tell me why this sed
is failing with I use in a qx()
in Perl?
Upvotes: 0
Views: 154
Reputation: 62096
$#JAVA_HOME
is treated as a Perl variable (the number of the last element of the array variable). Escape it: \$#JAVA_HOME
Upvotes: 4