题目:for循环打印下面这句话中字母数不大于6的单词
Bash also interprets a number of multi-character options.
演示1:
使用for循环轮询单词,使用wc -L判断单词长度,并做判断
#!/bin/bash
for f in Bash also interprets a number of multi-character options
do
[ `echo $f |wc -L ` -le 6 ] && echo $f
done
演示2:
使用数组的方式,直接读取数组中的元素,判断元素的长度
#! /bin/bash
aww=(Bash also interprets a number of multi-character options)
for file in ${aww[@]}
do
if [ ${#file} -le 6 ]
then
ehco $file
fi
done