shell——流程控制


1. for

#!/bin/bash

for file in $(ls *)
do
        echo $file
done

for ((p = 0; p < 10; p++))
do
        echo $p
done

2. select

select dir in /bin /usr/sbin quit
do
        if [ ! -z "${dir}" ]; then
                if [ ${dir} == "quit" ]; then
                        echo "Byebye !"
                else
                        echo "You chose $dir"
                fi
                break;

        else
                echo "Error , invaild selection \"$REPLY\", chose again !"
        fi
done