reading variables from a file

Hi,

Could anyone help me in understanding what I am missing..
I have a text file with the following info.

INFILE=>

#Name Variable=<value>
#---------------------------------
name1 inargs="-a Filename1.$VAR.csv -f Filename2.$VAR.csv -c File.c"
name1 incond="Filename1.$VAR.csv Filename2.$VAR.csv"

I want to get the inargs and incond when the name1 is given. I am doing the following -
NAME="$1" (and I pass name1 for NAME)
eval `grep -v \# $INFILE | awk "\\$1 == \"$NAME\" {print \\$2}", but I am getting nothing.

anyhelp is appreciated.

thanks.

#!/bin/ksh

NAME='name1'
file='tt.txt'

eval $(nawk -v q='"' -v name="${NAME}" '
  BEGIN {
   PATinags="inargs"
   PATincond="incond"
  }
  $1 == name {
      v="_unknown_"
      if ( $2 ~ ("^" PATinags) )
         v= PATinags
      if ( $2 ~ ("^" PATincond) )
         v= PATincond
      if (split($0, tmpA, q) >= 3 )
         printf("%s=\"%s\"\n", v, tmpA[2])
  }' "${file}" )

echo "inargs->[${inargs}] incond->[${incond}]"

Thanks a lot. that works..., I will try to understand how you have done it. I thought we might get it with the one line/two lines using awk.

Hi vgersh99,

could you explain what the split is doing in your solution..., thanks.

it splits a record/line with double-quote as a separtor splacing the results into an array tmpA.