Hi,
Is there any way to pass variable in awk statement. I am trying to write following script which will keep variable in array.
------------------------------------------------
sys="abc bcd dde ccc"
ctr=1
SYSNAME=${sysname[*]}
sysn=`echo $sys | awk '{print NF}'`
while [ $sysn -ge $ctr ]
do
sysname[$ctr]=`echo $sys | awk -F" " '{print $ctr}'`
((ctr=ctr+1))
done
--------------------------------------------------
It is showing following error
awk: Field $() is not correct.
The input line number is 1.
The source line number is 1.
Is there any other way to store those variable.
Thanks in advance.
Sandip
Is there any way to pass variable in awk statement. I am trying to write following script which will keep variable in array.
------------------------------------------------
sys="abc bcd dde ccc"
ctr=1
SYSNAME=${sysname[*]}
sysn=`echo $sys | awk '{print NF}'`
while [ $sysn -ge $ctr ]
do
sysname[$ctr]=`echo $sys | awk -F" " '{print $ctr}'`
((ctr=ctr+1))
done
--------------------------------------------------
It is showing following error
awk: Field $() is not correct.
The input line number is 1.
The source line number is 1.
Is there any other way to store those variable.
Thanks in advance.
Sandip