title: Insert Shell Command Output in Sed and replace existing file line
body: <p>I am trying to create a shell script, which needs to run on boot of new VPS Created. New VPS will be created with cPanel/WHM Panel pre-installed on CentOS 7 64bit template. Shell script needs to change the IP address of the VPS, with new IP address assigned to VPS while creation and reboot the cpanel service. </p>
  
  <pre><code>#!/bin/bash
  echo -e "\e[1;36;40m Modifying parameters in cpanel shared IP configuration \e[0m"
  ipchange="$(ip addr show | grep 'venet0:0' | awk '{ print $2}')"
  echo "$ipchange"
  sed -i -e 's/"ADDR 127.0.0.1$"/"ADDR $ipchange"/g' /etc/wwwacct.conf
  echo -e "\e[1;36;40m Restarting cPanel \e[0m"
  systemctl restart cpanel.service  &gt; /dev/null 2&gt;&amp;1
  echo -e "\e[1;36;40m Restart cpanel completed \e[0m"
  </code></pre>
  
  <p>I need to know how can I insert a partial output of below command</p>
  
  <pre><code>ip addr show | grep 'venet0:1' | awk '{ print $2}'
  </code></pre>
  
  <p>Example OUTPUT</p>
  
  <pre><code>bbb.bbb.bbb.bbb/32
  </code></pre>
  
  <p>Only need to copy <code>bbb.bbb.bbb.bbb</code> and insert in <code>/etc/wwwacct.conf</code> file by removing existing</p>
  
  <pre><code>ADDR 127.0.0.1
  </code></pre>
  
  <p>With new IP</p>
  
  <pre><code>ADDR bbb.bbb.bbb.bbb
  </code></pre>
  
  <p>Save the existing file and restart the cpanel services.</p>