要實現此功能只要使用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
命令相關參數介紹