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
