
저는 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.
}