开发者

Unix ksh validation

开发者 https://www.devze.com 2023-02-27 06:23 出处:网络
echo banana app开发者_运维知识库le pear grape melon orange lime read fruit1 fruit2 fruit3 Questions:
echo banana app开发者_运维知识库le pear grape melon orange lime
read fruit1 fruit2 fruit3

Questions: - How to test if the user input 3 arguments and not less? - How to test if the 3 arguments are in the list or if it is 3 out of these seven?

I read many things on the internet, I tried playing with s#, nothing is working.


i=0
for var in "banana apple pear grape melon orange lime read fruit1 fruit2 fruit3"
if [ "$var" == "$2" -o "$var" == "$3" -o "$var" == "$4" ]
then
++$i
fi


echo $i

if value of i is 3 then it means all the three command line arguments are present.

0

精彩评论

暂无评论...
验证码 换一张
取 消