2010. 8. 11. 17:07

안녕하세요~ 윈디안입니다.

오랜만에 포스팅 하네요... 여름 휴가 후에 게으름으로 인한 늦장이였습니다.  죄송합니다. (__)

오늘 이야기해 볼 것은 비교연산자(comparison operator)입니다. 

파워쉘 스크립트들을 예제를 보다 보면 -lt, -le, -eq 이런 녀석을 볼때가 있죠.
대충 분위기를 보면 값을 비교하는 것 같은데 정확한 의미를 알 수 없었습니다.
스크립트를 만들거나 개발을 하신 분들은 이미 익숙 하겠지만 저는 몰랐습니다.

아주 오래전에 비슷한 걸 배웠던 기억만 있었죠.

비슷한???

저는 이런 것을 배웠었거든요

= 같다
< 작다
> 크다
>= 크거나 같다.


느낌이 오시지 않습니까?

그렇습니다.

값을 비교해주는 연산자였던 것입니다.
그래서 비교연산자라고 하겠죠? ㅎㅎ

다음은 Windows PowerShell Quick Reference에 나와 있는 원문입니다.

How to Make Comparisons


Windows PowerShell cmdlets (like Where-Object) use a special set of comparison operators, including those shown in the following table.

 

Each of these operators can be made case sensitive by adding a c immediately after the hyphen. For example,   -ceq represents the case-sensitive equals operator; -clt is the case-sensitive less than operator.

 

-lt

Less than

-le

Less than or equal to

-gt

Greater than

-ge

Greater than or equal to

-eq

Equal to

-ne

Not equal to

-like

Like (uses wildcards for matching)

-notlike

Not like (uses wildcards for matching)

 


간단하게 정리하자면 아래와 같습니다.


-lt Less than 작다
-le Less than or equal to 작거나 같다
-gt Greater than 크다
-ge Greater than or equal to 크거나 같다
-eq Equal to 같다
-ne Not equal to 같지 않다
-like Like (uses wildcards for matching) 유사하다
-notlike Not like (uses wildcards for matching) 유사하지 않다

-c를 통해서 대소문자 구분 추가 가능
  ex> -clt, -cle

영어로 외워두시면 기억하기가 편할 것 같습니다.

원문에 보면 Case sensitive라는 것이 있습니다. 쉽게 대소문자 구분이라고 생각하시면 됩니다.
비교 연산자와 "-"사이에 c 를 추가하여 사용 할 수 있습니다.


참고 링크 : Windows PowerShell Quick Reference
ttp://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=df8ed469-9007-401c-85e7-46649a32d0e0

비교 연산자뿐 아니라 짧고 굵은 내용이 많습니다. 4쪽 밖에 되지 않으니 Powershell을 시작하시는 분은 꼭 읽어 보셨으면 합니다.

그럼 이만 이번 포스팅을 마치겠습니다.
감사합니다. ^^
Posted by 알 수 없는 사용자
:
BLOG main image
Windows Server를 공부 하는 사람들의 팀블로그 by 마성민

카테고리

분류 전체보기 (76)
Windows (2)
Powershell (56)
AD (0)
Exchange (6)
System Center (9)
IIS (0)
SQL (3)
Sharepoint (0)

태그목록

Tistory Cumulus Flash tag cloud by BLUEnLIVE requires Flash Player 9 or better.

Total :
Today : Yesterday :