I want to print the values from properties file dynamically I am using below code but getting wrong output.
testProperty.properties
edmcws,edmbws,edmwt
Code
file=/ThreadDump/testProperty.properties
count=$(head -1 $file | sed 's/[^,]//g' | wc -c)
echo "$count"
for((i=1;i<=$count;i++))
do
abc=$(awk -F "," '(NR==1){print $($i)}' $file)
echo "$abc"
done
Output
3
edmcws,edmbws,edmwt
edmcws,edmbws,edmwt
edmcws,edmbws,edmwt
But when I hard-code the value I am getting correct output.
Code
file=/ThreadDump/testProperty.properties
count=$(head -1 $file | sed 's/[^,]//g' | wc -c)
echo "$count"
for((i=1;i<=$count;i++))
do
abc=$(awk -F "," '(NR==1){print $1}' $file)
echo "$abc"
done
Output
3
edmcws
edmcws
edmcws