shell脚本:打印文本中字符数不大于6的单词

for循环打印下面这句话中字母数不大于6的单词;
I am oldboy teacher welcome to oldboy traning class

#!/bin/bash

num=0
array=(I am oldboy teacher welcome to oldboy traning class)
for i in ${!array[*]};
    do 
        len=`echo ${array[$i]} | wc -m`
        if [ $len -le 6 ];then
        num=$[$num+1]
        fi
    done
echo $num
此条目发表在linux分类目录,贴了, 标签。将固定链接加入收藏夹。