title: Redirect output to different files for sun grid engine array jobs (SGE)
body: <p>I am trying to execute a sun grid engine array job and I need a different output file per task: test.1.out test.2.out,etc..</p>
  
  <p>If I write my script like this:</p>
  
  <pre><code>#!/bin/bash
  #$ -S /bin/bash
  #$ -N name
  #$ -t 1-4000
  #$ -o /home/myuser/out/test.$TASK_ID.out
  #$ -e /home/myuser/err/test.$TASK_ID.err
  #$ -cwd
  #$ -V
  &lt;bash commands here&gt;
  </code></pre>
  
  <p>The files are called $TASK_ID.out (1.out,2.out,etc..) and at /home/myuser/</p>
  
  <p>And if I write my script like this:</p>
  
  <pre><code>#!/bin/bash
  #$ -S /bin/bash
  #$ -N name
  #$ -t 1-4000
  #$ -o /home/myuser/out/
  #$ -e /home/myuser/err/
  #$ -cwd
  #$ -V
  &lt;bash commands here&gt;
  </code></pre>
  
  <p>The files are located at the correct folder but evidently with the default name: name.o$JOB_ID.$TASK_ID</p>
  
  <p>What should I do?</p>