리눅스 egrep AND, OR, NOT

(Egrep AND, OR, NOT에서 넘어옴)

1 개요[ | ]

egrep AND
egrep OR
egrep NOT
  • 실제로 AND, OR, NOT에 해당하는 연산자가 있는 것은 아니다.
  • 비슷한 동작을 하게 할 수는 있다.

2 egrep AND[ | ]

  • user와 httpd가 모두 있는 행 보기
[root@zetawiki ~]# cat /etc/httpd/conf/httpd.conf | grep user | grep httpd
# If you wish httpd to run as a different user or group, you must run
# User/Group: The name (or #number) of the user/group to run httpd as.
[root@zetawiki ~]# cat /etc/httpd/conf/httpd.conf | egrep user | egrep httpd
# If you wish httpd to run as a different user or group, you must run
# User/Group: The name (or #number) of the user/group to run httpd as.
[root@zetawiki ~]# cat /etc/httpd/conf/httpd.conf | egrep 'httpd.*user|user.*httpd'
# If you wish httpd to run as a different user or group, you must run
# User/Group: The name (or #number) of the user/group to run httpd as.

3 egrep OR[ | ]

  • ftp 또는 apache 또는 sshd가 있는 행 보기
[root@zetawiki ~]# cat /etc/passwd | egrep 'ftp|apache|sshd'
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin

4 egrep NOT[ | ]

  • nologin이 없는 행 보기
[root@zetawiki ~]# cat /etc/passwd | egrep -v 'nologin'
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}