1 / 6

U N I X

U N I X. 창원대학교 전자계산학과 김병찬 . DB Lab . 목 차. 제어 흐름 명령 if then if then else if then elif for in for while until break, continue case 여기문서 exec 명령 trap 명령 함수. DB Lab . if test-command. false. true. Then command. fi. 제어 흐름 명령 . echo “word 1: c” read word1

dougal
Télécharger la présentation

U N I X

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. U N I X 창원대학교 전자계산학과 김병찬

  2. DB Lab. 목 차 • 제어 흐름 명령 • if then • if then else • if then elif • for in • for • while • until • break, continue • case • 여기문서 • exec 명령 • trap 명령 • 함수

  3. DB Lab. if test-command false true Then command fi 제어 흐름 명령 echo “word 1: \c” read word1 echo “word 2: \c” read word2 if test “$word1” = “$word2” then echo match fi echo End of program • If then \c 는 echo가 표시하는 문자열 다음에 오는newline을 억제. test utility : 첫번째와 세번째 인수가 두번째 인수에 지정된 관계가지면 참(=0).

  4. DB Lab. if test-command true false Then command else command fi 제어 흐름 명령 if [ $# = 0 ] then echo “usage: out [-v] filename” 1 >&2 exit 1 fi if [ “$1” != “-v” ] then cat -- “$@” else shift more -- “$@” fi • If then else $# 명령줄 인수의 수 -- 명령줄에 더 이상의 옵션이 없음

  5. DB Lab. if test-command true false elif test-command true false Then command Then command else command fi fi 제어 흐름 명령 Echo “word 1: \c” read word1 echo “word 2: \c” read word2 echo “word3: \c” read word3 if [ “$word1” = “$word2” -a “$word2” = “$word3” ] then echo “match: words 1,2, & 3” elif [ “$word1” = “$word2” ] then echo “match: words 1& 2” elif [ “$word1” = “$word3” ] then echo “match: words 1 & 3” elif [ “$word2” = “$word3” ] then echo “match: words 2 & 3” else echo no match fi • if then elif -a and연산 test 명령은 첫번째와 두번째 논리적 인 비교가 참일 때만 참 상태 반환 &를 특수 문자로 인식하지 않게 하기 위해 “” 사용

  6. DB Lab. if test-command false true Then command fi 제어 흐름 명령 echo “word 1: \c” read word1 echo “word 2: \c” read word2 if test “$word1” = “$word2” then echo match fi echo End of program • If then \c 는 echo가 표시하는 문자열 다음에 오는newline을 억제. test utility : 첫번째와 세번째 인수가 두번째 인수에 지정된 관계가지면 참(=0).

More Related