数组遍历


#!/bin/sh
function check(){
var=(gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel  zlib zlib-devel glibc glibc-devel glib2 glib2-devel)

echo "array's length is   ${#var[@]}"
#${array[@]}==${var[*]}
for name in ${var[*]} ; do

 command=$(rpm -qa  ${name})
if [ -z "${command}" ]; then
 echo "warnning ${name} is not exits"
exit 0
fi
done
}

check

你可能感兴趣的:(数组)