bash shell script two variables in for loop

前端 未结 7 1178
终归单人心
终归单人心 2020-12-09 19:33

I am new to shell scripting. so kindly bear with me if my doubt is too silly.

I have png images in 2 different directories and an executable which takes an images f

7条回答
  •  伪装坚强ぢ
    2020-12-09 20:16

    I have this problem for a similar situation where I want a top and bottom range simultaneously. Here was my solution; it's not particularly efficient but it's easy and clean and not at all complicated with icky BASH arrays and all that nonsense.

    SEQBOT=$(seq 0  5  $((PEAKTIME-5)))
    SEQTOP=$(seq 5  5  $((PEAKTIME-0)))
    
    IDXBOT=0
    IDXTOP=0
    
    for bot in $SEQBOT; do
        IDXTOP=0
        for top in $SEQTOP; do
            if [ "$IDXBOT" -eq "$IDXTOP" ]; then
                echo $bot $top
            fi
            IDXTOP=$((IDXTOP + 1))
        done
        IDXBOT=$((IDXBOT + 1))
    done
    

提交回复
热议问题