Hi,

Am 01.04.2014 um 00:36 schrieb Rahnamay Farnoud, Noushin/Sloan-Kettering 
Institute:

> Hello All,
> 
> I am new to SGE and have a problem understanding probably a very basic task.
> I am reading an example that runs a job array over a set of samples that 
> their names are in a text file (e.g., samples.txt).
> 
> Below are the two lines that suppose to link the sample names to task ID. But 
> can you please tell how the number of records NR

Number of the actual record.


> is used in this awk command to do this task?
> 
> # sample manifest - text file with one sample ID per line
> MANIFEST=/path/to/samples.txt
>  
> # dereference task ID to sample ID
> SAMPLE=`awk "NR==${SGE_TASK_ID}" ${MANIFEST}`

One can say it's clever `awk` programming: do the default action (i.e. to print 
the actual line of input, so the line NR of the input) if the conditions of the 
expression applies. Often you see single quotation marks and the value passed 
by a switch to the `awk` program:

$ SAMPLE=`awk -v foo=${SGE_TASK_ID} 'NR==foo' ${MANIFEST}`

but the initial one is shorter, as it insets the value of the `bash` variable 
directly. You can do the same with `sed`:

$ SAMPLE=`sed -ne ${SGE_TASK_ID}p ${MANIFEST}`

There are certain variable set in `awk` beforehand; you can search for "NR " in 
the awk-manpage to get to the point where all are listed.

-- Reuti


> Thank you very much for your help in advance.
> 
> Regards,
> 
> NF
> _______________________________________________
> users mailing list
> [email protected]
> https://gridengine.org/mailman/listinfo/users


_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to