运维网's Archiver
论坛
›
Shell/Powershell
› shell数组 只保留2个元素
sharpds77
发表于 2018-8-28 09:23:39
shell数组 只保留2个元素
while :;
read -p "pleas a number" n
do
c[$b]=$n;((b++))
echo ${c[@]}
echo ${#c[@]}
if [ ${#c[@]} -gt 2 ]
then
d=0
unset c[$d]
m=`echo ${c[@]}`
c=($m)
echo ${c[@]}
fi
done
页:
[1]
查看完整版本:
shell数组 只保留2个元素