ยง2023-09-09

In Bash, you can assign values to variables in several ways:

$ my_array=("apple" "banana" "cherry")
$ my_array=("apple" "banana" "cherry")
$ echo "${my_array[2]}"
cherry
$ echo "${my_array[0]}"
apple
alexlai@Surfa
MY_ENV_VAR="This is an environment variable"
my_var="$MY_ENV_VAR"
$ my_var="${MY_DEFAULT_VAR:-Default Value}"
$ echo $my_var
Default Value
$ my_var+=" more text"
$ echo $my_var
Default Value more text
$ num1=5
$ num2=3
$ result=$((num1 + num2))
$ echo $result 
8