상세 컨텐츠

본문 제목

[shell script] for문

shell script

by 빨간눈동자 2021. 10. 3. 09:00

본문

반응형
#!/bin/bash


for var in 1 2 3 4 5
do
    echo case#1 value : ${var}
done

echo -----------------

list="1 2 3 4 5"
for var in ${list}
do
    echo case#2 value : ${var}
done

echo -----------------
for var in {1..5}
do
    echo case#3 value : ${var}
done

echo -----------------
for var in {1..5..2}
do
    echo case#4 value : ${var}
done

echo -----------------
for var in $(seq 5)                # for var in $(seq 1 5)
do
    echo case#5 value : ${var}
done

echo -----------------
for var in $(seq -s " " 1 2 5)
do
    echo case#6 value : ${var}
done

 

반응형

관련글 더보기