Answers for "bash for if array together"

0

bash for if array together

for (( i=0; i<res_len; i++ ));
do

 if [[ $i -eq 0 ]];                             #for 1st in seq  #cheked using for (( i=6; i<=6; i++ )); work !
 then
        a=zero
        resnew[$i]=5${res[$i]}${res[$i+1]}    #5XX
#        echo $resnew[$i]

 elif [[ $i -eq $(($res_len-1)) ]];                    #for last in se #cheked using for (( i=6; i<=6; i++ )); work !
 then
        a=equal
        resnew[$i]=${res[$i-1]}${res[$i]}3    #XX3  
 #       echo $resnew[$i];
 else
        a=others
        resnew[$i]=${res[$i-1]}${res[$i]}${res[$i+1]}  #  AXA                                 
#        echo $resnew[$i];

 fi
done

exho ${res[1]}
echo $a
echo 0 5xx : ${resnew[0]}
echo 1 : ${resnew[1]}
echo 2 : ${resnew[2]}
echo 3 : ${resnew[3]}
echo 4 : ${resnew[4]}
echo 5 : ${resnew[5]}
echo last : ${resnew[$(($res_len -1))]}
Posted by: Guest on August-21-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language