grep详解
1.grep
grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。用于过滤/搜索的特定字符。可使用正则表达式能配合多种命令使用,使用上十分灵活
2.命令详解
1.grep hello 1.txt
区分大小写

2.grep -i hello 1.txt
不区分大小写

3.grep -w hello 1.txt
精确打印

4.grep -e hello -e today 1.txt
打印多个匹配项

5.grep -n hello 1.txt
显示行数

6.grep -r hello /home/
在指定目录下查找文件内容

7.grep -E 'hello|today' 1.txt
启用正则表达式

作者:
Shu-How Z
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。

浙公网安备 33010602011771号