Passion/bash
parameter 개수 확인
sunshout
2014. 4. 18. 21:58
root@cnode04-m:~# ./test.sh a b
The number of arguments is: 2
fail
root@cnode04-m:~# ./test.sh a b c
The number of arguments is: 3
success
going...
root@cnode04-m:~# cat test.sh
echo "The number of arguments is: $#"
if [ $# -eq 3 ]
then
echo "success"
else
echo "fail"
exit
fi
echo "going..."
728x90