その他 Tips
Sponsored Link

対話形式で処理を進める
2013/01/06

  対話型のシェルスクリプトサンプル
#!/bin/bash

while true
do
    echo -n "Are you sure to proceed? [y/n] :"
    read ANS

    if [ "${ANS}" = 'y' -o "${ANS}" = 'yes' ]; then
        break
    elif [ "${ANS}" = 'n' -o "${ANS}" = 'no' ]; then
        exit 1
    else
        continue 1
    fi
done

echo "finished"

関連コンテンツ