一直感慨AIX上面的grep命令的一个特性比GNU grep要好得多。
它可以列出包含搜索内容的段落,而不仅仅是行。
这尤其对类似 db2 list db directory 这样的命令结果有效。
但是Windows, Linux上面都没有拥有这个能力的工具。
初学python,刚好需要练习,于是自己做了一份。也算是自给自足了。
既然是搜索段落( Paragraph),就起了个名字,叫 pgrep。
可以从这里下载,下载完了记得改名字。
http://download.csdn.net/source/164755
为了方便广大没有安装python的Windows用户(也为了自己运行快一些),做成了一个Windows下的安装版本。
http://download.csdn.net/source/296203
使用帮助如下(为了走向世界,做成了英文的,好累…… ^_^; ):
------------------------------------
pgrep v1.00.x071127
by Programus (programus@gmail.com)
------------------------------------
An open source and free command line grep like tool.
It prints out the paragraphs which contains the pattern instead of lines.
Usage: pgrep [OPTION]... PATTERN [FILE] ...
<If you run from source code> python pgrep [OPTION]... PATTERN [FILE] ...
Search for PATTERN in each FILE or standard input and output a paragraph separated by separator.
Example: python pgrep.py -i 'hello world' menu.h main.c
OPTIONS:
-c, --count
Suppress normal output; instead print a count of matching lines for each input file.
With the -v, --invert-match option, count non-matching lines.
-e, --regexp=PATTERN
Use pattern as the pattern; useful to protect patterns beginning with a -.
-f, --file=FILE
Obtain patterns from file, one per line. The empty file contains zero patterns, and therefore matches nothing.
-h, --help
Print this help
-i, --ignore-case
Ignore case distinctions in both the pattern and the input files.
-l, --files-with-matches
Suppress normal output; instead print the name of each input file from which output would normally have been printed.
The scanning of every file will stop on the first match.
-p, --separator=SEPARATOR
Specify a separator. The default separator is '/n/s*/n'.
-v, --invert-match
Invert the sense of matching, to select non-matching parts.
它可以列出包含搜索内容的段落,而不仅仅是行。
这尤其对类似 db2 list db directory 这样的命令结果有效。
但是Windows, Linux上面都没有拥有这个能力的工具。
初学python,刚好需要练习,于是自己做了一份。也算是自给自足了。
既然是搜索段落( Paragraph),就起了个名字,叫 pgrep。
可以从这里下载,下载完了记得改名字。
http://download.csdn.net/source/164755
为了方便广大没有安装python的Windows用户(也为了自己运行快一些),做成了一个Windows下的安装版本。
http://download.csdn.net/source/296203
使用帮助如下(为了走向世界,做成了英文的,好累…… ^_^; ):
------------------------------------
pgrep v1.00.x071127
by Programus (programus@gmail.com)
------------------------------------
An open source and free command line grep like tool.
It prints out the paragraphs which contains the pattern instead of lines.
Usage: pgrep [OPTION]... PATTERN [FILE] ...
<If you run from source code> python pgrep [OPTION]... PATTERN [FILE] ...
Search for PATTERN in each FILE or standard input and output a paragraph separated by separator.
Example: python pgrep.py -i 'hello world' menu.h main.c
OPTIONS:
-c, --count
Suppress normal output; instead print a count of matching lines for each input file.
With the -v, --invert-match option, count non-matching lines.
-e, --regexp=PATTERN
Use pattern as the pattern; useful to protect patterns beginning with a -.
-f, --file=FILE
Obtain patterns from file, one per line. The empty file contains zero patterns, and therefore matches nothing.
-h, --help
Print this help
-i, --ignore-case
Ignore case distinctions in both the pattern and the input files.
-l, --files-with-matches
Suppress normal output; instead print the name of each input file from which output would normally have been printed.
The scanning of every file will stop on the first match.
-p, --separator=SEPARATOR
Specify a separator. The default separator is '/n/s*/n'.
-v, --invert-match
Invert the sense of matching, to select non-matching parts.