Bash script tutorial with a minimum example

It uses variable, function, for loop, if else:

#!/bin/bash

function hi() {
    #no matter what get print out, it will get returned
    author=$1
    echo "${author}: \n"
    echo "hi,\n";
    echo "you";
}

#yingshaoxo="$(echo yingshaoxo)"
yingshaoxo="yingshaoxo"
var=$(hi $yingshaoxo)

echo -e $var
echo -e $var
echo -e "\n"

my_list=("dog" "human" "cat");
for word in ${my_list[@]}; do
    if [[ $word == "human" ]] ; then
        echo "${word} !!!"
    elif [[ $word == "dog" ]]; then
        echo "$word ."
    else
        echo $word
    fi
done

exit

The bash syntax is similar to PHP, which treats list and map data structure as one single object.

Use declare -A map_name to declare a map

Use declare -a list_name to declare a list


More info: 

https://www.geeksforgeeks.org/bash-scripting-array

https://linuxize.com/post/bash-arrays/#creating-associative-arrays

https://www.xmodulo.com/key-value-dictionary-bash.html