티스토리 뷰

공부

[Sh] count parameter

승가비 2020. 5. 17. 21:13
728x90
if [ "$#" -eq 2 ]
then
    echo "Its works!"
else
    echo "need to two params"
exit 1
fi

https://stackoverflow.com/questions/4341630/checking-for-the-correct-number-of-arguments

 

Checking for the correct number of arguments

How do i check for the correct number of arguments (one argument). If somebody tries to invoke the script without passing in the correct number of arguments, and checking to make sure the command l...

stackoverflow.com

 

728x90

'공부' 카테고리의 다른 글

[Sh] check disk size (df & du)  (0) 2020.05.17
[Sh] merge files  (0) 2020.05.17
[VueJS] style scope  (0) 2020.05.17
[SQL] IF EXISTS `NAME`  (0) 2020.05.17
[Markdown] details > summary  (0) 2020.05.17
댓글