Bash script as altering the mass element
-
How can you replace the element in bash? For example, if the third element in the volume number 3 needs to be replaced by 2 equal to 3-1, it makes a mistake.
-
#! /bin/bash $ declare -a arr=(a b c) $ echo ${arr[*]@A} declare -a arr=([0]="a" [1]="b" [2]="c") $ echo ${arr[2]} c $ declare -i IDX=3 $ echo ${arr[$(( IDX - 1 ))]} c $ arr[$(( IDX - 1 ))]="d" $ echo ${arr[$(( IDX - 1 ))]} d $ echo ${arr[*]@A} declare -a arr=([0]="a" [1]="b" [2]="d")