![쉘 스크립트를 종료하는 방법은 무엇입니까?](https://linux55.com/image/56646/%EC%89%98%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EC%A2%85%EB%A3%8C%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
저는 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.
}