展开全部
将下面的内容存入文件中,比如test.sh,然后chmod +x test.sh 变成可执行,然后 ./test.sh 99 100 -1 -80 .... 参数可以是任意多数字
#!/bin/bash
if [ -z "$1" ]; then
echo "You have to provide at least one numbers"
exit 1
fi
max=$1
min=$1
for number in $*
do
if [ $number -gt $max ]; then
max=$number
fi
if [ $number -lt $min ]; then
min=$number
fi
done
echo "Max $max, Min $min"
#!/bin/bash
if [ -z "$1" ]; then
echo "You have to provide at least one numbers"
exit 1
fi
max=$1
min=$1
for number in $*
do
if [ $number -gt $max ]; then
max=$number
fi
if [ $number -lt $min ]; then
min=$number
fi
done
echo "Max $max, Min $min"
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询