title: How do I append lines in a bash script using sed command?
body: <p>The problem with my infrastructure is the SMTP server IP Address is dynamic.. I use Vyatta firewall &amp; I'm trying to write a script which will check for the SMTP IP every 60mins and if the SMTP IP is changed it should automatically update the firewall rules (configuration)..</p>
  
  <pre><code>#!/bin/bash
  
  SMTP=$(nslookup smtp.sendgrid.net | awk -F': ' 'NR==6 { print $2 }')
  SMTP_IP=x.x.x.x
  
  if [ $SMTP != $SMTP_IP ]
  then
  ???
  else
  echo "GREEN"
  fi
  </code></pre>
  
  <p>My Firewall rules looks like this:</p>
  
  <pre><code>    rule 979 {
          destination {
              address "Current SMTP IP"
          }
          outbound-interface bond1
          source {
              address 10.x.x.x
          }
          translation {
              address 200.x.x.x
          }
      }
  </code></pre>
  
  <p>I would like my script to update the firewall rules from the previous rule.. Example:</p>
  
  <pre><code>.
  .
  .    
  rule 978 {
      destination {
          address "NEW SMTP IP"
      }
      outbound-interface bond1
      source {
          address 10.x.x.x
      }
      translation {
          address 200.x.x.x
      }
  }
  </code></pre>
  
  <p>I'm a Network guy &amp; have some basic knowledge in scripting. Can someone help me in solving this using a bash script ???</p>