Skip to main content
More precise title, grammar, tags, markup and small rearrangement of oddly placed section
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

unix cat the file content from text Insert contents of file into XML attribute

I have a text file called branch.txt and it has list of users as line belowbranch.txt:

cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970
$ cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970

Using the above branch name i, I have to find and replace some valuevalues using seda sed command:

branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file
branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file

When i running sedI run the sed command i'm gettting, I get an error like the one below.:

cat /tmp/input.file
<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>
sed: -e expression #1, char 35: unterminated `s' command
sed: -e expression #1, char 35: unterminated `s' command

Expected output:

<Project description="first-deployment" name="DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 " overwrite="true" type="Repository">
      </Project>
<Project description="first-deployment" name="DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 " overwrite="true" type="Repository">
      </Project>

Input file:

<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>

unix cat the file content from text file

I have text file called branch.txt and it has list of users as line below

cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970

Using above branch name i have to find and replace some value using sed command

branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file

When i running sed command i'm gettting error like below.

cat /tmp/input.file
<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>
sed: -e expression #1, char 35: unterminated `s' command

Expected output

<Project description="first-deployment" name="DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 " overwrite="true" type="Repository">
      </Project>

Insert contents of file into XML attribute

I have a text file called branch.txt:

$ cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970

Using the above branch name, I have to find and replace some values using a sed command:

branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file

When I run the sed command, I get an error like the one below:

sed: -e expression #1, char 35: unterminated `s' command

Expected output:

<Project description="first-deployment" name="DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 " overwrite="true" type="Repository">
      </Project>

Input file:

<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>
Added Expcted outout
Source Link
viswa
  • 23
  • 4

I have text file called branch.txt and it has list of users as line below

cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970

Using above branch name i have to find and replace some value using sed command

branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file

When i running sed command i'm gettting error like below.

cat /tmp/input.file
<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>
sed: -e expression #1, char 35: unterminated `s' command

Expected output

<Project description="first-deployment" name="DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 " overwrite="true" type="Repository">
      </Project>

I have text file called branch.txt and it has list of users as line below

cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970

Using above branch name i have to find and replace some value using sed command

branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file

When i running sed command i'm gettting error like below.

cat /tmp/input.file
<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>
sed: -e expression #1, char 35: unterminated `s' command

I have text file called branch.txt and it has list of users as line below

cat branch.txt
DEMAND_NAME-CR-1234
DEMAND_NAME-CR-8970

Using above branch name i have to find and replace some value using sed command

branch_name=`(cat /tmp/branch.txt)`
sed -i "s/deploy_branch/$branch_name/g" /tmp/input.file

When i running sed command i'm gettting error like below.

cat /tmp/input.file
<Project description="first-deployment" name="deploy_branch" overwrite="true" type="Repository">
      </Project>
sed: -e expression #1, char 35: unterminated `s' command

Expected output

<Project description="first-deployment" name="DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 " overwrite="true" type="Repository">
      </Project>
edited tags
Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
edited body
Source Link
viswa
  • 23
  • 4
Loading
added 144 characters in body
Source Link
viswa
  • 23
  • 4
Loading
Source Link
viswa
  • 23
  • 4
Loading