The for loop and an array of small shell script Case

Use a for loop and an array of shell prints the following phrase in English is not greater than the number of letters in the word 5:

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

The old rules, the first analysis:
1. Find the focus, for the array and
2-letter word book less than 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


The second method
for Word value in $ {[*]}
do
IF [ expr length $word-LT-. 5]; the then
echo $ Word
Fi
DONE


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

testing successfully

 There are many methods, you can try ~

Guess you like

Origin blog.51cto.com/14573101/2447225