I am new to both scripting and SGE, so I don't understand why, but I
need to escape all the variables in my script. For example,
awk "NR==$SGE_TASK_ID" /myPath/fileList.txt
produces a blank output, but if I escape the env variable, like:
awk "NR==\$SGE_TASK_ID" /myPath/fileList.txt
then I get the correct line from the text file. The problem is when I
try to assign this output to a variable. I still need to use the
escape, but I think it's not being passed correctly.
Thanks,
Sara
On Apr 16, 2012, at 10:27 PM, Rayson Ho wrote:
It works for bash too... except with the "escape" one you are using:
#!/bin/bash
export SGE_TASK_ID=2
line2=`awk -v task_id=$SGE_TASK_ID 'NR==task_id' "/tmp/fileList.txt"`
echo $line2
line2=$(awk -v "task_id=$SGE_TASK_ID" 'NR==task_id' "/tmp/
fileList.txt" )
echo $line2
line2=$(awk -v "task_id=$SGE_TASK_ID" 'NR==task_id' "/tmp/
fileList.txt" )
echo \$line2
[rayson@computer source]$ ./sh
L2
L2
$line2
Why are you doing "echo \$line2"?
Rayson
On Tue, Apr 17, 2012 at 1:21 AM, Sara Rolfe
<[email protected]> wrote:
I'm using bash.
Thanks,
Sara
On Apr 16, 2012, at 10:20 PM, Rayson Ho wrote:
What shell are you using??
Rayson
On Tue, Apr 17, 2012 at 1:15 AM, Sara Rolfe <[email protected]
>
wrote:
Hi Rayson,
Thanks for your reply. I have tried using -v to pass variables
to awk,
but
it is not working correctly. I think it's because my script
requires all
variables to be escaped and I don't know how to pass the escape
symbol
correctly.
line2=$(awk -v "task_id=$SGE_TASK_ID" 'NR==task_id'
"/myPath/fileList.txt" )
echo \$line2
has a blank output, but so does
line2=$(awk -v "task_id=\$SGE_TASK_ID" 'NR==task_id'
"/myPath/fileList.txt"
)
echo \$line2
Can you give me any insight into passing the escape sign or why I
am
needing
to escape all the variables in my script?
Thanks,
Sara
On Apr 16, 2012, at 9:13 PM, Rayson Ho wrote:
line2=$(awk -v "task_id=$SGE_TASK_ID" 'NR==task_id' "/tmp/
fileList.txt" )
_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users