Shell——expr应用案例:打印下面字符串中字符数不大于6的单词

脚本:

#!/bin/bash

for i in I am the a hero and you must to learning py
do
    if [ `expr length $i` -le 6 ]
        then 
            echo $i
    fi
done
 

执行结果:

 Shell——expr应用案例:打印下面字符串中字符数不大于6的单词