Arrays 为什么我的bash脚本不能正常工作?

Arrays 为什么我的bash脚本不能正常工作?,arrays,bash,grep,Arrays,Bash,Grep,我编写了下面的bash脚本,用于使用config.xml文件调整图像(icon.png)的大小,其中包含保存调整大小的文件所需的图像大小和链接 #!/usr/bin/env bash function help { echo "For running the program, please write" echo "1) config.xml file's location containing image sizes and links for saving resized image

我编写了下面的bash脚本,用于使用config.xml文件调整图像(icon.png)的大小,其中包含保存调整大小的文件所需的图像大小和链接

#!/usr/bin/env bash
function help {
  echo "For running the program, please write"
  echo "1) config.xml file's location containing image sizes and links for saving resized images;"
  echo "2) a name of an image to be resized."
}

function resize {
  array=()
  while read -r line
  do
    case $line in *icon*) array+=("$line");; esac
  done < $1
  for ((a=0; a < ${#array[*]}; a++))
  do
    echo "$a: ${array[$a]}"
    imagesize=$(echo "$a: ${array[$a]}" | grep "<icon"| grep -E -o "height=\"(\d+)" | grep -E -o "\d+")
    imagelink=$(echo "$a: ${array[$a]}" | grep "<icon"| grep -E -o "[^\"\'=[:space:]]+\.(jpe?g|png|gif)")
    echo $2 -resize $imagesizex$imagesize! ../../$imagelink
  done
  echo "Resizement has been executed"
}

if [ ! -f "$1" ] || [ ! -f "$2" ]
then
  help
else
  resize
fi
#/usr/bin/env bash
功能帮助{
echo“要运行程序,请编写”
echo“1)config.xml文件的位置,其中包含用于保存已调整大小的图像的图像大小和链接
echo“2)要调整大小的图像的名称
}
函数调整大小{
数组=()
而read-r行
做
*图标*)数组+=(“$line”);esac中的大小写$line
已完成<$1
for((a=0;a<${#数组[*]};a++)
做
回显“$a:${array[$a]}”

imagesize=$(echo“$a:${array[$a]}”| grep”共享您面临的错误。我得到以下错误:“第9行:$1:dimensional redirect”在函数$1中将调用函数resize更改为“resize$1$2”表示传递给函数而不是脚本的第一个参数
<icon height="36" width="36" density="ldpi" src="res/icon/android/ldpi.png"/>.