OS_Linux&Unix

[Linux/Unix] grep / egrep 차이점?

최선을 다하자! 2022. 9. 21. 15:14

grep 과 egrep 의 차이점은 없다.

다만 쓰이는 패턴은 다르다.

 

 

확장 정규표현식 egrep과 기본 정규표현식 grep의 차이는 아래와 같다.

 

egrep은 grep 명령어에 -E 또는 --extended-regexp 옵션을 준 것과 같다.

 

의미는 'OR' 이다. 또는.

 

 

기본 정규표현식에서는 메타문자 각각에 대하여 \ 문자를 통해 escape 처리를 해주어야 동작하게 된다.

egrep  'no(escape|character)' someFile

grep 'no\(escape\|character\)' someFile

 

이러한 차이 말고는 100% 동일하게 사용된다.

 

1. grep 

find ./ -mtime -30 |xargs grep -s  "error" ULOG.*
ULOG.081422:124043.tuxedo!tmshutdown.24184.1810002368.-2: FATAL: internal error: CMDTUX_CAT:764: ERROR: can't attach to BB
ULOG.081522:194609.tuxedo!tmboot.6951.2460131776.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081522:194706.tuxedo!tmboot.7020.3002724800.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:001925.tuxedo!tmboot.24305.1717105088.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:001937.tuxedo!tmboot.24317.840610240.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:002020.tuxedo!tmboot.24398.3811217856.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:002030.tuxedo!tmboot.24408.3820057024.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
./test_nxa.pc:          printf("\nDB connect error! : sqlcode = %d\n", sqlca.sqlcode);
./ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
./ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
./ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
./ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
./ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
./ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found

 

 

2. egrep

 

find ./ -mtime -30 |xargs egrep -s  "error" ULOG.*
ULOG.081422:124043.tuxedo!tmshutdown.24184.1810002368.-2: FATAL: internal error: CMDTUX_CAT:764: ERROR: can't attach to BB
ULOG.081522:194609.tuxedo!tmboot.6951.2460131776.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081522:194706.tuxedo!tmboot.7020.3002724800.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:001925.tuxedo!tmboot.24305.1717105088.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:001937.tuxedo!tmboot.24317.840610240.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:002020.tuxedo!tmboot.24398.3811217856.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.081622:002030.tuxedo!tmboot.24408.3820057024.-2: CMDTUX_CAT:825: ERROR: Process WSL at simple failed with /T tperrno (TPESYSTEM - internal system error)
ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
./test_nxa.pc:          printf("\nDB connect error! : sqlcode = %d\n", sqlca.sqlcode);
./ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
./ULOG.090122:095959.tuxedo!tmshutdown.11478.604955072.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
./ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
./ULOG.092022:155023.tuxedo!tmboot.16859.524120576.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found
./ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:754: ERROR: error processing configuration file
./ULOG.092122:103405.tuxedo!tmboot.3070.3044831744.-2: FATAL: internal error: CMDTUX_CAT:1360: ERROR: configuration file not found