要實現此功能只要使用grep
命令就好啦,具體可以看下下邊這個小例子:
查詢/home目錄及其子目錄中所有包含”hello”字串的檔案,並顯示出該字串在檔案中所處的行數。
[root@localhost ~]# grep -nR "hello" /home /home/a:8:hello,world! /home/b/a:10:hello,it7e!
grep
命令相關引數介紹
- -n 是顯示行號
- -R 查詢所有檔案包含子目錄
- -i 忽略大小寫
要實現此功能只要使用grep
命令就好啦,具體可以看下下邊這個小例子:
查詢/home目錄及其子目錄中所有包含”hello”字串的檔案,並顯示出該字串在檔案中所處的行數。
[root@localhost ~]# grep -nR "hello" /home /home/a:8:hello,world! /home/b/a:10:hello,it7e!
grep
命令相關引數介紹