The -E option specifies grep to use extended regular expressions. The feature of extended regular expressions I am using is:
(c|b)at
This matches "cat" or "bat" i.e. only one of the options in the round brackets are chosen. So in your case the grep command will match
Package: iptables-mod-
Package: kmod-ipt-
Package: kmod-nf
Package: .*nfnetlink
Package: .*netfilter
Package: .*iptables
To gain better knowledge of regular expressions please use http://www.grymoire.com/Unix/Regular.html as a reference. Regular expressions form the basis of grep, sed, awk, find and many other UNIX commands. So it is a big advantage if you have a good grasp of regular expressions. Enjoy!
发布评论
评论(1)
您可以用以下 grep 命令完全替换 grep 命令:
-E 选项指定 grep 使用扩展正则表达式。我正在使用的扩展正则表达式的特点是:
它匹配“cat”或“bat”,即仅选择圆括号中的选项之一。因此,在您的情况下, grep 命令将匹配
要更好地了解正则表达式,请使用http://www.grymoire.com/Unix/Regular.html作为参考。正则表达式构成了 grep、sed、awk、find 和许多其他 UNIX 命令的基础。因此,如果您很好地掌握了正则表达式,那将是一个很大的优势。享受!
You can replace the grep command entirely by this grep command:
The -E option specifies grep to use extended regular expressions. The feature of extended regular expressions I am using is:
This matches "cat" or "bat" i.e. only one of the options in the round brackets are chosen. So in your case the grep command will match
To gain better knowledge of regular expressions please use http://www.grymoire.com/Unix/Regular.html as a reference. Regular expressions form the basis of grep, sed, awk, find and many other UNIX commands. So it is a big advantage if you have a good grasp of regular expressions. Enjoy!