shell习题 – 查找字母数小于6的单词


用shell打印下面这句话中字母数小于6的单词。
Bash also interprets a number of multi-character options.

 

参考答案:

#!/bin/bash

for s in Bash also interprets a number of multi-character options

do

n=`echo $s|wc -c`

if [ $n -lt 6 ]

then echo $s

fi

done