2020/Shell Script(4)
-
쉘 스크립트 기본 문법 4 (break, continue, 함수선언)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 #! /bin/bash #1 select name in john bob tom do case $name in john ) echo "Hey, John!" ;; bob ) echo "Hey, Bob!" ;; tom ) echo "Hey, Tom!" ;; esac done #2 for (( i=0; i> $file fi else echo "File does not exist" fi } if [ $..
2020.04.30 -
쉘 스크립트 기초 문법 3 (while, for)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #! /bin/bash #1 while loop num=0 while [ $num -le 10 ] do echo $num #(( num++ )) #$(expr $num + 1 ) num=$(( num+ 1 )) done #2 함수의 인자로 파일의 내용을 받아서 출력한다. while read line do echo $line done
2020.04.30 -
쉘 스크립트 기초 문법 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 #! /bin/bash #1 echo -e "Type any number here (0~9): \c" read num case $num in [0-9] ) echo "You typed a correct charcter" if [ $num -ge 0 ] && [ $num -le 9 ] then echo "Great!" fi ;; [a-z] ) echo "$num is wro..
2020.04.30 -
쉘 스크립트 기초 문법 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #! /bin/bash #1 echo -e "Enter your name : \c" read name echo $name #2 echo -e "Enter fruits : \c" read -a fruits echo ${fruits[0]} echo ${fruits[1]} echo ${fruits[2]} #3 echo $0 $1 $2 $3 #4 num=10 name='eunhwan' file='test.txt' if [ $num -gt 0 ] then echo "$num is grater than 0" else e..
2020.04.30