title: Unix cut except last two tokens
body: <p>I'm trying to parse file names in specific directory. Filenames are of format:</p>
  
  <pre><code>token1_token2_token3_token(N-1)_token(N).sh
  </code></pre>
  
  <p>I need to cut the tokens using delimiter <code>'_'</code>, and need to take string except the last two tokens. In above examlpe output should be <code>token1_token2_token3</code>.</p>
  
  <p>The number of tokens is not fixed. I've tried to do it with <code>-f#-</code> option of <code>cut</code> command, but did not find any solution. Any ideas?</p>