linux中查找某一个字符串,linux下查找包含某个字符串的文件
linux下查找包含某個(gè)字符串的文件 | Rootop 服務(wù)器運(yùn)維與web架構(gòu)
比如在當(dāng)前路徑下有個(gè)test文件夾,其中包含 a、b、 c、d.c 四個(gè)文件,內(nèi)容如下:
[root@rhel6www ~]# pwd
/root
[root@rhel6www ~]# ll -d test/
drwxr-xr-x 2 root root 4096 Apr 11 02:15 test/
[root@rhel6www ~]#
[root@rhel6www test]# cat a
venus
[root@rhel6www test]# cat b
venusnq
[root@rhel6www test]# cat c
saslkdjfalsdkjflk
[root@rhel6www test]# cat d.c
hahahvenus
現(xiàn)在需要尋找包含“venus”字符串的文件。
[root@rhel6www ~]# find test/ -type f | xargs grep “venus”
test/a:venus
test/b:venustsui
test/d.c:hahahvenus
find + 搜索目錄 -type f 只尋找文件。
這樣是搜索所有文件,在linux下,,軟件源碼包中有.h 、.c文件,如果我們從*.c 中搜索某個(gè)字符串??梢赃@樣。
[root@rhel6www ~]# find test/ -type f -name “*.c” | xargs grep “venus”
hahahvenus
這樣排除了部分文件,提高效率。
總結(jié)
以上是生活随笔為你收集整理的linux中查找某一个字符串,linux下查找包含某个字符串的文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle / parallle /,
- 下一篇: Linux内核源码行数,Linux源代码