ループ

for

 IFS='
 '
 for line in `cat /etc/passwd`; do
    echo $line
 done

while

引数

 while [ $# -gt 0 ]; do
    echo $1
    shift
 done

カウントダウン

 try=10
 while [ "$try" -gt 0 ]; do
    try=`expr "$try" - 1`
 done

breakで抜ける

 while : ; do
    if date '+%S' | grep '00'; then
        echo hit
        break
    fi
    echo -n .
    sleep 1
 done

readコマンドを使って入力を読み取る

 cat /etc/passwd | while read line; do
     echo $line    
 done

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS