'정규표현식'에 해당되는 글 2건

  1. 2009.10.12 awk에서 정규표현식 match
  2. 2008.10.11 [UnixTip] awk에서의 정규표현식 match

awk에서 정규표현식 matching

다음의 명령을 사용하고자 한다면

command | grep pattern | awk '{print $3}'

이 명령은 awk에서의 정규표현식 matching기능을 이용하여 다음과 같이 간단히
사용할 수 있다.

command | awk '/pattern/{print $3}'

--------------------<원문>---------------------
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 3171 - October 12, 2009

                   http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

REGEXP MATCHING IN AWK

If you ever find yourself typing "command | grep pattern | awk '{print $3}'
you can shorten this by using the regexp matching in awk, like this:

command | awk '/pattern/{print $3}'

반응형
Posted by She쥐포s

어떤 명령을 실행한 결과에서 일정패턴을 찾아 그 결과중 일정부분을 찾으려고 했을때
다음과 같이 입력하는 경험을 해본적이 있을 것이다.
물론 나도 그랬으니까...

$ command | grep PATTERN | awk '{ print $3 }'

위의 문장은 awk의 특성을 이용하여 다음과 같이 줄여 쓸 수 있다.

$ command | awk '/PATTERN/{ print $3 }'

-------------------------<원문>-------------------------
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP
                       Unix Tip 3171 - October 11, 2008
                   http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

REGEXP MATCHING IN AWK

If you ever find yourself typing "command | grep pattern | awk '{print $3}'
you can shorten this by using the regexp matching in awk, like this:

command | awk '/pattern/{print $3}'

반응형
Posted by She쥐포s
이전버튼 1 이전버튼

블로그 이미지
She쥐포s
Yesterday
Today
Total

달력

 « |  » 2024.4
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

최근에 올라온 글

최근에 달린 댓글

글 보관함