I have the following sed command:
sed -i 's#^.*BRANCH_NAME=.*$#\tBRANCH_NAME=$(egrep \\"${project}\\" localFile.xml | sed -n 's_.*changeset=\"\([^\"]\+\).*_\1_p')#' myCfgFile.cfg
basically I'm trying to substitute a line starting with BRANCH_NAME= from myCfgFile.cfg with something else like: BRANCH_NAME=$(egrep \\"${project}\\" localFile.xml | sed -n 's_.*changeset=\"\([^\"]\+\).*_\1_p')
The bad news is that I can't preserve the content of BRANCH_NAME=$(egrep \\"${project}\\" localFile.xml | sed -n 's_.*changeset=\"\([^\"]\+\).*_\1_p')
literally, because I get it interpreted.
So, is there any way that I can keep the content as it is, without having it interpreted by sed? As I said above, I'm trying to replace a line (BRANCH_NAME=) with something else (*BRANCH_NAME=$(egrep \"${project}\" localFile.xml | sed -n 's_.changeset=\"([^\"]+)._\1_p')*)
I would really appreciate your help. Thanks
EDIT
Actually I'm dealing with 3 files:
One List of paths to projects (below is the format)
/home/myDir/proj1
/home/myDir/proj1/extended
(...)
An .xml file containing project names and their corresponding changesets
<project name="/home/myDir/proj1/extended" path="/home/myDir/proj1/extended" changeset="3c57f20f89de07e1490aac56d1e8aba5848150b5" />
By executing a for loop I get following:
for project in (cat projectlis); do
egrep \\"${project}\\" localFile.xml | sed -n 's_.*changeset=\"\([^\"]\+\).*_\1_p')#' myCfgFile.cfg
done
- A bash script that I'm not allowed to change and commit :) this script does contain a wrong line defining a variable
BRANCH_NAME=*
and before executing the script that I'm not allowed to commit, I'd like to change (from Jenkins inline script) the wrong line
BRANCH_NAME=*
with
BRANCH_NAME=$(egrep \\"${project}\\" localFile.xml | sed -n 's_.*changeset=\"\([^\"]\+\).*_\1_p')`
I hope this is a bit more clear.
Thanks