#!/bin/bash
arr=( #定义数组 arr =()
I am english teacher welcome to english training class
)
len=${#arr[*]} #取数组长度不是$(#arr[*])
echo $len
for(( i=0; i < len; i++ ))
do #[]中括号各空一个空格否则报错 testfor.sh: line 10: [1: command not found
if [ `expr length ${arr[$i]}` -le 6 ] #[]中是-le非<=报错testfor.sh: line 10: =: No such file or directory
then #取变量的值是$变量即arr[$i]非arr[i]
echo "${arr[$i]}"#$(arr[i])报错testfor.sh: line 12: arr[0]: command not found
fi
done