I did find answers to this question, what I don't understand is why what seems to work for other is not working for me. I have a text file with a list of sample names. I want to extract these samples names individually and assign it to a variable, in order to run an array job.
The file is a samples.txt:
sample_id_a
sample_id_b
sample_id_c
Using the command:
qsub -t 1-3 test_job.sh
My script is the following: Using the task id index, I want to retrieve the sample id of line x and assign it to VAR, then print it.
#!/bin/bash
echo "The increment is ${SGE_TASK_ID}"
VAR=$(awk 'NR==${SGE_TASK_ID}' samples.txt)
echo " The sample is ${VAR}"
The output is:(here example for output number 1)
The increment is 1
The sample is
So SGE_TASK_ID is correct, but I fail to retrieve and echo the corresponding string in my .txt file.
Thank you, Camille