表达式 | 意义 |
---|---|
grep -c hello test* | 查询文件test1、testa、testjsd 中包含“hello”的行数 |
grep -n hello test* | 查询文件test1、testa、testjsd 中包含“hello”的行的内容,如 test1 中第一行 hello word |
grep -i hello test* | “-i ” 表示忽略大小写、查询文件test1、testa、testjsd 中包含“hello”、"Hello"的行的内容 |
grep -l hello * | "-l" 表示查询包含“hello”的文件,即只输出文件名,对我们查询代码内具体关键字比较有用 |
grep -r hello newDir | “-r” 表示递归查询,即:查询当前目录下及子目录下包含“hello”的文件 |
grep -w n*w newfile | 表示搜索newfile包含 n*w 的行,即:可以当做忽略了正则 |
grep常用表达式---------shell基础篇(二)
最新推荐文章于 2022-09-22 22:16:05 发布