quarta-feira, 28 de junho de 2017

Loop 'for'

#!/bin/bash
for i in $( ls ); do
    echo item: $i
done
#!/bin/bash
for i in `seq 1 10`; do
    echo item: $i
done
#!/bin/bash
for i in $(seq 1 10); do
    echo item: $i
done
#!/bin/bash
for ((i=1; i=10; i++)); do
    echo item: $i
done

Loop 'while'

#!/bin/bash 
COUNTER=0
while [  $COUNTER -lt 10 ]; do
    echo The counter is $COUNTER
    let COUNTER=COUNTER+1 
done

Loop 'until'

#!/bin/bash
COUNTER=20
until [  $COUNTER -lt 10 ]; do
    echo COUNTER $COUNTER
    let COUNTER-=1
done

0 comentários: