[root@promote opt]# grep -v '^$' httpd.conf
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
[root@promote opt]# grep -n 'th[ie]' httpd.conf
:# This is the main Apache HTTP server configuration file. It contains the
:# configuration directives that give the server its instructions.
:# Do NOT simply read the instructions in here without understanding
:# what they do. They're here only as hints or reminders. If you are unsure
[root@promote opt]# grep -n 'oo' httpd.conf
:# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
:# with ServerRoot set to '/www' will be interpreted by the
:# ServerRoot: The top of the directory tree under which the server's
:# ServerRoot at a non-local disk, be sure to specify a local disk on the
:# same ServerRoot for multiple httpd daemons, you will need to change at
[root@promote opt]# grep -n '[^w]oo' httpd.conf
:# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
:# with ServerRoot set to '/www' will be interpreted by the
:# ServerRoot: The top of the directory tree under which the server's
:# ServerRoot at a non-local disk, be sure to specify a local disk on the
:# same ServerRoot for multiple httpd daemons, you will need to change at
:ServerRoot "/etc/httpd"
:# LoadModule foo_module modules/mod_foo.so
:# httpd as root initially and it will switch.
:# It is usually good practice to create a dedicated user and group for
:ServerAdmin root@localhost
:# DocumentRoot: The directory out of which you will serve your
:DocumentRoot "/var/www/html"
:# Further relax access to the default document root:
: # Redirect permanent /foo http://www.example.com/bar
: # access content that does not live under the DocumentRoot.
:#ErrorDocument "The server made a boo boo."
:wooo
:woooo
[root@promote opt]# grep -v '^[a-zA-Z]' httpd.conf
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
^括号在[]外的代表以什么什么开头的 在[]内表示取反 反过滤
[root@promote opt]# grep -n '[0-Z]' httpd.conf
[root@promote opt]# grep -n '[0-Z]' httpd.conf
:# This is the main Apache HTTP server configuration file. It contains the
:# configuration directives that give the server its instructions.
:# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
:# In particular, see
:# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
:# for a discussion of each configuration directive.
:# Do NOT simply read the instructions in here without understanding
:# what they do. They're here only as hints or reminders. If you are unsure
:# consult the online docs. You have been warned.
:# Configuration and logfile names: If the filenames you specify for many
```handlebars
[root@promote opt]# grep -n '^root' /etc/passwd
:root:x:::root:/root:/bin/bash
[root@promote opt]# grep -n 'bash$' /etc/passwd
:root:x:::root:/root:/bin/bash
:shang:x:::shang:/home/shang:/bin/bash
[root@promote opt]# grep -n '\.$' httpd.conf
:# configuration directives that give the server its instructions.
:# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
:# for a discussion of each configuration directive.
:# interpreted as '/log/access_log'.
:# configuration, error, and log files are kept.
[root@promote opt]# grep -n 'ooo*' httpd.conf ^C
:woo
:wooo
:woooo
[root@localhost ~]# grep -n 'woo*d' test.txt
:a wood cross! :#woood # :#woooooood #
[root@localhost ~]# grep -n 'w.*d' test.txt
:he was short and fat.
:google is the best tools for search keyword. :a wood cross!
:Actions speak louder than words :#woood #
:#woooooood #
[root@localhost ~]# grep -n '[0-9][0-9]*' test.txt :
the tongue is boneless but it breaks bones.!
:PI=3.141592653589793238462643383249901429
[root@localhost ~]# grep -n 'wo\{2,\}d' test.txt
:a wood cross!
:#woood # :#woooooood #
egrep 当使用多个表达式双重多重过滤 执行“grep -v‘^KaTeX parse error: Expected group after '^' at position 21: ….txt | grep -v‘^̲#’”即可实现。这里需要使用管…|^#’test.txt”,其中,单引号内的管道符号表示或者(or)。
'+ '作用:重复一个或者一个以上的前一个字符 与※不同的是 ※可以匹配0次而+不能
[root@promote opt]# egrep -n 'wo+' httpd.conf
:# particular features to be enabled - so if something's not working as
: # It can be "All", "None", or any combination of the keywords:
:# be turned off when serving from networked-mounted
:wo
:woo
:wooo
:woooo
[root@promote opt]# grep -n 'wo\+' httpd.conf
:# particular features to be enabled - so if something's not working as
: # It can be "All", "None", or any combination of the keywords:
:# be turned off when serving from networked-mounted
:wo
:woo
:wooo
:woooo
[root@promote opt]# grep -n 'wo\?' httpd.conf
:# filesystems or if support for these functions is otherwise
:wo
:woo
:wooo
:woooo
egrep -n 'wo?' httpd.conf
:# filesystems or if support for these functions is otherwise
:wo
:woo
:wooo
:woooo
‘*’ 和‘?’一样 都是匹配前一个字符0或者多次 ‘+’ 是匹配前一个字符 一次或者多次 等同于大括号 里面一次 这里还是大括号最精确 匹配指定次数
[root@promote opt]# grep -n 'wo\{1,\}' httpd.conf
:# particular features to be enabled - so if something's not working as
: # It can be "All", "None", or any combination of the keywords:
:# be turned off when serving from networked-mounted
:wo
:woo
:wooo
:woooo
grep的所有功能全部都能实现 并且使用特殊字符 + ? 不用加转义 两次过滤直接用管道符过滤就可以