title: How to use AWK inside SED
body: <p>I'm trying to remove some word from a string in file. The problem is that there are more occurrence of this word in the file.</p>
  
  <p>I need to remove host-name from the file so I am doing:</p>
  
  <pre><code>   less /etc/dhcp/dhclient.conf | grep host-name 
  </code></pre>
  
  <p>and this is what I am getting:</p>
  
  <pre><code>send host-name = gethostname();
      domain-name, domain-name-servers, domain-search, host-name,
  #  option host-name "andare.swiftmedia.com";
  </code></pre>
  
  <p>So now I tried using awk:</p>
  
  <pre><code>less /etc/dhcp/dhclient.conf | grep host-name | awk 'NR&gt;1 {print $4}'
  host-name,
  "andare.swiftmedia.com";
  </code></pre>
  
  <p>But I have no idea how can I remove this from a file on a specific occurrence (on second occurrence)</p>
  
  <p>both sed and awk always make me confused :/
  Your help would be much appreciated.</p>
  
  <p><strong>EDIT:</strong>
  <strong>Current /etc/dhcp/dhclient.conf</strong></p>
  
  <pre><code># Configuration file for /sbin/dhclient.
  #
  # This is a sample configuration file for dhclient. See dhclient.conf's
  #       man page for more information about the syntax of this file
  #       and a more comprehensive list of the parameters understood by
  #       dhclient.
  #
  # Normally, if the DHCP server provides reasonable information and does
  #       not leave anything out (like the domain name, for example), then
  #       few changes must be made to this file, if any.
  #
  
  option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
  
  send host-name = gethostname();
  request subnet-mask, broadcast-address, time-offset, routers,
          domain-name, domain-name-servers, domain-search, host-name,
          dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
          netbios-name-servers, netbios-scope, interface-mtu,
          rfc3442-classless-static-routes, ntp-servers;
  </code></pre>
  
  <p>I need to remove host-name from the line starting from request.</p>
  
  <p><strong>Expected:</strong></p>
  
  <pre><code># Configuration file for /sbin/dhclient.
  #
  # This is a sample configuration file for dhclient. See dhclient.conf's
  #       man page for more information about the syntax of this file
  #       and a more comprehensive list of the parameters understood by
  #       dhclient.
  #
  # Normally, if the DHCP server provides reasonable information and does
  #       not leave anything out (like the domain name, for example), then
  #       few changes must be made to this file, if any.
  #
  
  option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
  
  send host-name = gethostname();
  request subnet-mask, broadcast-address, time-offset, routers,
          domain-name, domain-name-servers, domain-search,
          dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
          netbios-name-servers, netbios-scope, interface-mtu,
          rfc3442-classless-static-routes, ntp-servers;
  </code></pre>
  
  <p>Regards</p>