SHELL:某个数值是否在列表之中?
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[root@oracle-cluster-3 shell]# cat match_list.sh list_a="2 3 5 67 90" current_num=91 after_all=108 is_in="no" for list_item in $list_a do #echo "current in list is: [$list_item]" if [ $list_item -gt $current_num ] then is_in="yes" fi #echo "" done echo "current num is: [$current_num]" echo "does current num in the list? [$is_in]" [root@oracle-cluster-3 shell]# [root@oracle-cluster-3 shell]# sh match_list.sh current num is: [91] does current num in the list? [no] [root@oracle-cluster-3 shell]# [root@oracle-cluster-3 shell]# |
——————————————
Done。[……]