Unix ksh validation
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.
精彩评论