고급 Ubuntu

Shell script

If 문

if [ "$DISPLAY" == "localhost:0.0" ]
then
    echo "DISPLAY is set"
else
    echo "DISPLAY is not set"
fi

case 문

case "$DISPLAY" in
    "localhost") echo "DISPLAY is set only host address";;
    "localhost:0") echo "DISPLAY is set (0)";;
    "localhost:0.0") echo "DISPLAY is set (0.0)";;
    *) echo "DISPLAY is not set";;
esac

while 문

a=0
while [ "$a" -lt 10 ]
do
    echo $a
    ((a++))
done

until 문

a=0
until [ "$a" -eq 10 ]
do
    echo $a
    ((a++))
done

for 문

for i in 1 3 5
do
    echo "outer: $i"
    for j in `seq 11 3 17`
    do
        echo "inner: $j"
    done
done
for file in /etc/*
do
 ls $file
done

댓글

댓글 본문