[Linux] 주석 없는 라인만 보고싶다면? grep -v 명령어
특정 텍스트파일 혹은 설정 파일등을 확인할 때 주석이 많아 보기가 불편했던 경험은 누구나 한 두번쯤 있지 않을까?
아래는 httpd.conf의 일부분이다.
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used. If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
파일을 확인할 때 주석은 제외하고 보고싶을때 아래 명령어중 하나를 사용하자.
# cat /etc/httpd/conf/httpd.conf_bak | grep -v '^#' | less
# grep -v '^#' /etc/httpd/conf/httpd.conf_bak | less
결과
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf