Shell script “for” loop syntax

前端 未结 11 937
攒了一身酷
攒了一身酷 2020-12-07 07:11

I have gotten the following to work:

for i in {2..10}
do
    echo \"output: $i\"
done

It produces a bunch of lines of output: 2

11条回答
  •  天命终不由人
    2020-12-07 07:53

    Here it worked on Mac OS X.

    It includes the example of a BSD date, how to increment and decrement the date also:

    for ((i=28; i>=6 ; i--));
    do
        dat=`date -v-${i}d -j "+%Y%m%d"` 
        echo $dat
    done
    

提交回复
热议问题