CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): Zaharang (미친놈)
날 짜 (Date): 1996년04월17일(수) 22시33분53초 KST
제 목(Title): Re: Shell script



%나 #는 korn shell에서 자주 써먹는 value change기법인데

말로 설명하기 어렵군유.  항상 이런건 매뉴얼을 보는게 기본 상식이지요.

*공익광고*  귀찮더라도 매뉴얼을 한번은 뒤적거립시다!

자. 이제 매뉴얼을 보면

$man ksh

blah blah.
.
.
     ${parameter%pattern}
     ${parameter%%pattern}
               If the shell pattern matches the end of the  value
               of  parameter, then the value of this substitution
               is the value of the  parameter  with  the  matched
               part  deleted;  otherwise, substitute the value of
               parameter.  In the first form the smallest  match-
               ing  pattern is deleted and in the second form the
               largest matching pattern is deleted.   The  result
               is unspecified when parameter is @, *, or an array
               variable with subscript @, or *.

말이 좀 난해한데 %는 뒤에서부터이고 #은 앞에서부터 매치하는게
있으면 잘라낸다는 소리입니다.

그리니까 paramenter가 babo/bak이고 pattern이 bak이면
babo/가 저장된다는 사실.

따라서 위의 기법은 확장자 제거나 풀 패스에서 상대 패스로 바꾸는 편법에
쓰임.


@음. 기억나는거 보니까 내가 옥수수쉘 강의해서 둔받는사람이 맞군.


--------------------------------------------------------------------
크카카... 왜냐고?  난 천재니까..
천재를 너의 상식으로 이해하려고 하지 말아랑.
흥! 뭐라고?  내가 보기에 넌 조금 특이한 찐따에 지나지 않아.
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.