I want to append the value as $EC5 in my newlist in shell script. However, it is currently storing value as 11 in newlist array.
EC2=0
EC3=0
EC4=0
EC5=11
return_codes=( $EC2 $EC3 $EC4 $EC5)
newlist=()
for i in "${return_codes[@]}";
do
if [[ $i -ne 0 ]]
then
newlist+=($i)
fi
done
Kindly Help.
$EC5is11. Or do you mean you want to store the stringEC5itself? Leave out the$then. When you runreturn_codes=( $EC2 $EC3 $EC4 $EC5 ), that doesreturn_codes=( 0 0 0 11 ); the place where each of those numbers originally came from is lost.[shell]so you should add the proper tag for the shell you are using.[bash]?