루프
while
while [ condition ]
do
command1
command2
done
무한루프
#!/bin/bash
number = 0
while :
do
if [ $number -gt 2 ]; then
break
fi
echo "Number : ${number}"
((number++))
done
특정 파일 생성을 대기
#!/bin/bash
vFileLocation = "s3://bucket-name/sample.file"
while :
do
vCount = `aws s3 ls ${vFileLocation} | wc -l`
if [[ "${vCount}" == "1" ]]; then
echo "file check done."
break
fi
echo "file waiting..."
sleep 2m
done
for
for [ 배열_아이템 ] in [ 배열 ]
do
command1
${배열_아이템}
done
숫자 데이터를 이용한 반복
#!/bin/bash
for vTime in {1..100}
do
echo ${vTime}
done
포맷에 맞는 숫자 반복
#!/bin/bash
for vTime in {00..23}
do
echo ${vTime}
done
배열을 통한 반복
#!/bin/bash
vArray=(A B C)
for vItem in "${vArray[@]}"
do
echo $vItem
done
조건절