로켓🐾
article thumbnail
반응형

!/bin/sh
hap=0
for i in 1 2 3 4 5 6 7 8 9 10
  do
        hap=`expr $hap + $i`
  done
echo "1부터 10까지의 합:"$hap

hap2=0
for((i=0;i<=10;i++))
  do
        hap2=`expr $hap2 + $i`
  done
echo "1부터 10까지의 합:"$hap2

hap3=0
for fname in $(ls *.sh)
  do
        head -3 $fname
  done

exit 0

 

#!/bin/sh
hap=0
i=1
while test $i -le 10
  do
        hap=`expr $hap + $i`
        i=`expr $i + 1`
  done
echo "1부터 10까지의 합:"$hap
exit 0
#!/bin/sh
echo "비밀번호를 입력하세요"
read mypass
while test $mypass != "1234"
  do
        echo "틀렸음. 다시 입력하세요"
        read mypass
  done
echo "통과"
exit 0

 

 

#!/bin/sh
echo "무한반복 입력을 시작합니다. (b:break, c:continue, e:exit)"
while test 1
  do
        read input
        case $input in
          b|B)
                break;;
          c|C)
                echo "continue를 누르면 while의 조건으로 돌아감"
                continue;;
          e|E)
                echo "exit를 누르면 프로그램을 완전히 종료함"
                exit 1;;
        esac
  done
exit 0
반응형
profile on loading

Loading...