title: Shell Script: Truncating String
body: <p>I have two folders full of trainings and corresponding testfiles and I'd like to run the fitting pairs against each other using a shell script.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>for x in SpanishLS.train/*.train
  do
      timbl -f $x -t SpanishLS.test/$x.test
  done
  </code></pre>
  
  <p>This is supposed to take <code>file1(-n).train</code> in one directory, look for <code>file1(-n).test</code> in the other, and run them trough a tool called <code>timbl</code>.
  What it does instead is look for a file called <code>SpanishLS.train/file1(-n).train.test</code> which of course doesn't exist.
  What I tried to do, to no avail, is truncate <code>$x</code> in a way that lets the script find the correct file, but whenever I do this, <code>$x</code> is truncated way too early, resulting in the script not even finding the <code>.train</code> file.</p>
  
  <p>How should I code this?</p>