title: Sed command to extract substring of character separated words in a string
body: <p>Given a string such as <code>abc-def-ghi-jkl</code>.<br>
  Can the <code>sed</code> command extract the substring to the left of the nth separator character such as <code>abc</code> for 1, <code>abd-def</code> for 2 etc?</p>
  
  <p>I need it for making creating files based on a subset of the computers hostname, normally <code>abc-def-xyz.domain.com</code>.</p>
  
  <p>Having looked around it appears that <code>awk</code>, <code>cut</code> and <code>sed</code> are combined in this kind of extractions but I prefer something that can be used as part of a command line.</p>