I have a doubt. When i declare a value and assign to some variable, I don't know how to reassign the same value to another variable. See the code snippet below.
Here is my actual script.
#!/bin/sh
a=AA
b=BB
c=CC
d=DD
e=EE
f=FF
alpha_array=(a b c d e f)
process_array=(proc1 proc2 proc3 proc4)
array_1=("")
array_2=("")
display_array() {
echo "array1 = ${array_1[@]}"
echo "array2 = ${array_2[@]}"
}
checkarg() {
if [[ " ${alpha_array[*]} " == *" $token "* ]]; then
echo "alphabet contains $token "
array_1=("${array_1[@]}" "$token")
$token=${$token}
echo "TOKEN = $token"
elif [[ " ${process_array[*]} " == *" $token "* ]]; then
echo "process contains $token "
array_2=("${array_2[@]}" "$token")
else
echo "no matches found"
display_array
exit 1
fi
}
for token in $@
do
echo $token
checkarg
done
display_array
Here the below two lines
$token=${$token}
echo "TOKEN = $token"
should display my output as
TOKEN = AA
TOKEN = BB
when i run my script with the following arguments.
./build.sh a b proc1
Kindly help me out on those 2 lines.
$token=${$token}to do? That is, if it operated correctly, what would it accomplish?array_1=("${array_1[@]}" "$token")isarray_1+=( "$token" )-- both shorter to write and faster execution.