シェルスクリプトを終了するには?

シェルスクリプトを終了するには?

私はLinuxでスクリプトを書いていますが、少し追加のコンテンツを追加し、ユーザーにプログラムを終了するかどうかを尋ねたいと思います。これを行う方法を見つけるのに役立つ人はいますか?

ベストアンサー1

この試み:

read -p "Do you want to continue? (y/N) " ANS
    # if not, do something else, otherwise fall out the bottom
    [ "$ANS" = "y" -o "$ANS" = "Y" ] && {
            # commands here what to do if we stick around
            echo "OK, we will continue"
            # better put something else to do here or we'll fall out anyway.
            }

おすすめ記事