I want to use sed in order to replace one path with a different path,
I have this log4j file:
# suppress inspection "UnusedProperty" for whole file
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
spark.log.path=/tmp/logs/spark
msg.layout=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] (%F:%L) : %m%n
Now I want to change the path after "spark.log.path=" to a new one, the log4j file is always changing so I don't want to replace the path string, I want to replace the path after matching the 'spark.log.path='
I tried this shell script but it doesn't work (exception):
origin_path='spark.log.path='
k8s_path='spark.log.path=/tmp/logs/spark/master'
sed -i 's/^'${origin_path}' .*$/'${k8s_path}'/' log4j.properties
Can Anyone see what am I missing?