Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello, here is my issue -
I am running a script with a while loop. I have an awk statement within the while loop that uses an incremented variable. the script does not like me to use a variable in the awk statement.
Here is a snippet of the script where I am having the problem:
____________________________________
integer i=0while (( ( i += 1 ) < $NUMTAB )) do
TABNAME=$(awk 'NR==${i}' /backup/tables.txt)
print "export_def_table DEV "$TABNAME" ~ecs/backup/"$TABNAME".exp"done
______________________________________This part of the loop is giving me the error:
TABNAME=$(awk 'NR==${i}' /backup/tables.txt)It doesn't like when I use ${i} in the awk statement.
Can anyone help me with this??
Thanks!

Use double-quotes instead of single-quotes, and that will allow the shell to evaluate $i:
awk "NR==${i}"

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |