Below lines in configuration file to be replaced with java path, but do not replace java where you have java.base and java.lang.
JAVA_VERSION=$(“java” -version 2>&1 | awk -F ‘”‘ ‘/version/ {print $2}’)
$java -DagentVersion=2.6.0 –add-opens java.base/java.lang=ALL-UNNAMED –add-opens java.base/java.lang.reflect=ALL-UNNAMED -jar
Expected output : replaced java in both lines with /opt/java17 but do not edit & exclude java matched in the area (java.base/java.lang) of same line.
JAVA_VERSION=$(“/opt/java17” -version 2>&1 | awk -F ‘”‘ ‘/version/ {print $2}’)
$/opt/java17 -DagentVersion=2.6.0 –add-opens java.base/java.lang=ALL-UNNAMED –add-opens java.base/java.lang.reflect=ALL-UNNAMED -jar
tried below in ansible task
- replace:
path: "/tmp/config.txt"
regexp: '^(?!.*java[.])(?=java)(.*)$'
replace: '/opt/java171'
sheekay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.