Example 1

#!/bin/bash
#$ -cwd
#$ -t 1-10
#$ -N test
#$ -j y
#$ -o stdout.$JOB_ID.$TASK_ID
#$ -l h_rt=00:10:00,h_data=1g

echo 'hello' $SGE_TASK_ID

After the run, there will be 10 output files:

$ ls stdout*
stdout.475262.1   stdout.475262.2  stdout.475262.4  stdout.475262.6  stdout.475262.8
stdout.475262.10  stdout.475262.3  stdout.475262.5  stdout.475262.7  stdout.475262.9

For example:

$ cat stdout.475262.1
hello 1