利用for循环和shell数组打印下面这段话英文字母数不大于5的单词:

You have the most beautiful age, do not disappoint your best self

老规矩,首先分析:
1.找重点,for 和数组
2.字母书小于5的单词

value=(You have the most beautiful age, do not disappoint your best self)
for ((i=0;i<${#value[*]};i++))
do
if [ ${#value[$i]} -lt 5 ]
then
echo ${value[$i]}
fi
done


第二种方法
for word in ${value[*]}
do
if [ expr length $word -lt 5 ];then
echo $word
fi
done


[root@node1 ~]# sh test.sh
You
have
the
most
age,
do
not
your
best
self

测试成功

 方法还有很多,大家可以试试~