"Bash getopts 예제"의 두 판 사이의 차이

잔글 (로봇: 자동으로 텍스트 교체 (-[root@jmnote +[root@zetawiki))
36번째 줄: 36번째 줄:
==같이 보기==
==같이 보기==
*[[Bash 스크립트 인수 있는지 검사]]
*[[Bash 스크립트 인수 있는지 검사]]
*[[getopts]]
*[[리눅스 getopts]]
*[[case]]
*[[case]]



2015년 6월 15일 (월) 01:57 판

bash getopts example
Bash getopts 예제

1 소스

#!/bin/sh
while getopts "c:i:" arg
do
    case $arg in
    c)	CONGIF_FILE=$OPTARG ;;
    i)	IP_ADDRESS=$OPTARG ;;
    esac
done

echo CONFIG_FILE = [$CONGIF_FILE]
echo IP_ADDRESS = [$IP_ADDRESS]

2 실행결과

[root@zetawiki ~]# sh test.sh -c hello.cfg -i 123.45.67.89
CONFIG_FILE = [hello.cfg]
IP_ADDRESS = [123.45.67.89]
[root@zetawiki ~]# sh test.sh -i 123.45.67.89
CONFIG_FILE = []
IP_ADDRESS = [123.45.67.89]
[root@zetawiki ~]# sh test.sh
CONFIG_FILE = []
IP_ADDRESS = []

3 같이 보기

4 참고 자료

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