Calling array inside awk

Hello I have the file df.tmp
FS[1] is actually the / FS but escape character\ and end of line $ is used in order to fetch exctly / and not other filesystems.
awk '/\/$/ {print $(NF-1)+0}' df.tmp will work properly and return a value eg. 60
but when I am trying to issue the command with the array variable it will not work.

Please for your help.

FILE:
---------
(SERVER1)/export/home/>cat df.tmp
rpool/ROOT/s10u9 14680064 4972219 3416388 60 /
...
...
...
 
SCRIPT:
---------
#!/bin/ksh
FS[1]="\/$"
awk '/${FS[1]}/ {print $(NF-1)+0}' df.tmp

Thank you in advance for your help.

Try:

#!/bin/ksh
FS[1]="\/$"
awk '/'"${FS[1]}"'/ {print $(NF-1)+0}' df.tmp
1 Like

It works.

Thanks a lot

Welcome :slight_smile: