I am trying to insert dynamic elements to Any array after reading from a file. I am using ksh & i am getting error.
cat /user/may/onlySysVols
DATA4
DATA5
OSS90
SYSTEM
AUDIT
DATA1
DATA2
DATA3
cat tst.sh
1. i=0
2. grep -Ev "OSS|SYSTEM|AUDIT|VD|LAKE|$escvol" /user/may/onlySysVols |\
3. while read lin
4. do
5. eval ${sysVolArray}'[$i]'="\$lin"
6. ((i+=1))
7. done
8.
9. echo "${sysVolArray[*]}"
Output:
./tst.sh[5]: [0]=$DATA1: not found
./tst.sh[5]: [1]=$DATA2: not found
./tst.sh[5]: [2]=$DATA3: not found
./tst.sh[5]: [3]=$DATA4: not found
./tst.sh[5]: [4]=$DATA5: not found
Desired O/P(Printing an array)
DATA1 DATA2 DATA3 DATA4 DATA5
我知道了:它在第5行中应该是eval sysVolArray [$ i] =“ \\ $ lin”(没有$ {sysVolArray})
您可以使它更简单
sysVolArray=( $(grep -Ev "OSS|SYSTEM|AUDIT|VD|LAKE|$escvol" /usr/may/onlySysVols) )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.