linux - How to append to a specific line using shell script? -
i have file (catalina.properties) specific line of:
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar"
in environment looks this:
common.loader=
i need command appends part @ right side of equal sign, , works in both of 2 cases, result be:
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.base}/extra/part.jar"
or in other case:
common.loader="${catalina.base}/extra/part.jar"
sed solution:
exemplary test input file testfile
:
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar" common.loader= "ddd""sdsd"
sed 's~common\.loader=.*~&,"${catalina.base}/extra/part.jar"~; s/=,/=/' testfile
the output:
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.base}/extra/part.jar" common.loader="${catalina.base}/extra/part.jar" "ddd""sdsd"
Comments
Post a Comment