shell

linux command

Some open source projects

My notes

关于 shell 中的符号

数据类型

有字符串和整型数字(declare -i var) 注意申明赋值时等于号两边不要有空格

数据结构

只有一个 array, declare -a array_one

逻辑控制流

if

if condition; then
    do_something
fi

if condition; then
    do_something
else
    do_another_thing
fi

if condition; then
    do_something
elif condition; then
    do_another_thing
else
    do_yet_another_thing

for

for (( init; condition; step ))
do
    do_something
done

while

while condition
do
    do_something
done

until

until condition
do
    do_something
done

case

case $variable in
    condition)
        do_something
        ;;
    condition)
        do_something
        ;;
        ...
esca

函数

function_name() {
    do_something
}