start=1; total=0; while [ $start -le 1000 ];do [[ $(($start%2)) == 0 ]]&&total=$(($total+$start)); start=$(($start+1)); done; echo $total; [chengmo@centos5 ~]$ start=1;total=0;while [ $start -le 1000 ];do [[ $(($start%2)) == 0 ]]&&total=$(($total+$start)); start=$(($start+1));done;echo $total; 250500
start=0; total=0; for i in $(seq $start 2 1000); do total=$(($total+$i)); done; echo $total; [chengmo@centos5 ~]$ start=0;total=0;for i in $(seq $start 2 1000); do total=$(($total+$i));done;echo $total; 250500
[chengmo@centos5 ~]$ time (start=0;total=0;for i in $(seq $start 2 1000); do total=$(($total+$i));done;echo $total;) 250500 real 0m0.016s user 0m0.012s sys 0m0.003s [chengmo@centos5 ~]$ time (start=1;total=0;while [ $start -le 1000 ];do [[ $(($start%2)) == 0 ]]&&total=$(($total+$start)); start=$(($start+1));done;echo $total;) 250500 real 0m0.073s user 0m0.069s sys 0m0.004s
seq [OPTION]... LAST seq [OPTION]... FIRST LAST seq [OPTION]... FIRST INCREMENT LAST [chengmo@centos5 ~]$ seq 1000 ‘起始默认是 1,间隔默认也是1 [chengmo@centos5 ~]$seq 2 1000 ‘间隔默认是1 [chengmo@centos5 ~]$seq 1 3 10 '从1开始,到10 间隔为3 结果是:1 4 7 10 说明:默认间隔是“空格” 如果想换成其它的可以带参数:-s [chengmo@centos5 ~]$seq -s'#' 1 3 10 1#4#7#10
[chengmo@centos5 ~]$ a=($(seq 1 3 10))
[chengmo@centos5 ~]$ echo ${a[1]}
4
[chengmo@centos5 ~]$ echo ${a[@]}
1 4 7 10
[chengmo@centos5 ~]$ seq -s '#' 30 | sed -e 's/[0-9]*//g' #############################
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有