Bash 스크립트 인수 있는지 검사

Jmnote bot (토론 | 기여)님의 2015년 2월 12일 (목) 00:18 판 (로봇: 자동으로 텍스트 교체 (-[root@jmnote +[root@zetawiki))
Bash no arguments warning
Bash 스크립트 인수 있는지 확인

1 테스트 소스

#!/bin/bash
if [ $# -eq 0 ] ; then
    echo "Warning: no arguments"
    exit 0
fi
echo "OK"

2 실행 결과

[root@zetawiki ~]# sh test.sh 
Warning: no arguments
[root@zetawiki ~]# sh test.sh asdf
OK
[root@zetawiki ~]# sh test.sh 1
OK
[root@zetawiki ~]# sh test.sh 1 2
OK

3 같이 보기

4 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}