linux命令学习手册-grep命令内容摘要:

tFile中有至少 5个连续小写字符的字符串的行 : $ grep 39。 [az]\{5\}39。 testFile 输入之后,输出如下: hello, this is a file mand of grep. yes yeeeeeees i knooooooww! this is a world which is tes good. westeses westeseses west tesves *显示 testFile中有开头至少 5个连续小写字符的字符串的行 : $ grep 39。 ^[az]\{5,\}39。 testFile 输入之后,输出如下: hello, this is a file mand of grep. which is tes good. westeses westeseses *显示 testFile中含有以 th为开始的单词的行: $ grep 39。 \th39。 testFile 输入 之后,输出如下: hello, this is a file this file used for test the the west is this is a world 这里,以 th为开始的单词有: this和 the。 *显示 testFile中含有以 st结尾的单词的行: $ grep 39。 st\39。 testFile 输入之后,输出如下: this file used for test the the west is west tes west tesves 这里,以 st结尾的单词有 test和 west。 *利用标记的搜索: $ grep 39。 w\(es\)t t\1v\139。 testFile 输入之后,输出如下: west tesves 这里,根据正则表达式 \(\)括号内的内容 es匹配之后会被标记为 1,这样以后可以用\1来代替 es了。 这里相当于搜索: grep 39。 west tesves39。 testFile。 如果用 egrep或 grep E,就不用 \号进行转义可以直接用 1这个标号了。 【描述】 grep是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。 Unix的 grep家族包括 grep、 egrep和 fgrep。 egrep和 fgrep的命令只跟 grep有很小不同。 egrep是 grep的扩展,支持更多的 re元字符, fgrep就是 fixed grep或 fast grep,它们把所有的字母都看作单词,也就是说,正则表达式中的元字符表示回其自身的字面意义,不再特殊。 linux 使用 GNU版本的 grep。 它功能更强,可以通过 G、 E、 F命令行选项来使用 egrep和 fgrep的功能。 grep的工作方式是这样的,它在一个或多个文件中搜索字符串模板。 如果模板包括空格 ,则必须被引用,模板后的所有字符串被看作文件名。 搜索的结果被送到。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。