Cycle through words that are not greater than or less than 6 alphanumeric

Source: Internet
Author: User

  1. [email protected] scripts]# cat array02.sh

  2. #!/bin/sh

  3. array= (William Randolph Hearst was one of the richest men in 1903.)

  4. #1

  5. for Word in ${array[*]}

  6. Do

  7. if [${#word}-le 6];then

  8. Echo $word

  9. Fi

  10. Done

  11. Echo-e "\033[32m======================\033[0m"

  12. #2

  13. for ((i=0; i<${#array [*]}; i++))

  14. Do

  15. if [${#array [$i]}-le 6];then

  16. echo ${array[$i]}

  17. Fi

  18. Done

  19. Echo-e "\033[32m======================\033[0m"

  20. #3

  21. chars= "William Randolph Hearstis one of the richest men in 1903."

  22. for n in $chars

  23. Do

  24. [${#n}-gt 6] && {

  25. Echo $n

  26. }

  27. Done

This article from "Randolph" blog, reproduced please contact the author!

Cycle through words that are not greater than or less than 6 alphanumeric

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.