shell 九九乘法表

for i in {1..9}; do
    for ((j = 1; j <= i; j++)); do
        count=$((j * i))
        if [[ "$i" == "$j" ]]; then
            printf "%s*%s=\e[1;36m%s\e[0m\n" "$j" "$i" "$count"
        else
            printf "%s*%s=\e[1;36m%s\e[0m\t" "$j" "$i" "$count"
        fi
    done
done

输出示例

iShot_2022-08-08_11.05.22.png