ubuntu find命令

师兄面试金山的一道面试题,记录一下,就是要在某个指定的目录下找某个指定的文件,并把它输出。


find . -type f -exec grep demo1 -il {} \;


.代表当前目录   这里可以指定你要查找的路径;

type -f 指定查找的类型是文件类型

grep demo1  匹配demo1该字符串

-i或--ignore-case   忽略字符大小写的差别。

-l或--file-with-matches   列出文件内容符合指定的范本样式的文件名称。
-L或--files-without-match   列出文件内容不符合指定的范本样式的文件名称。

 {  }表示find查找到的东西,存入在{}里          

-exec表示find的额外动作,直到/结束

扫描二维码关注公众号,回复: 1271866 查看本文章


joe@ubuntu:~/erlangTest$ find . -type f -exec grep DEMO1 -il {} \;
./demo1.erl
./demo1.beam

 

以后继续补充grep的用法。


猜你喜欢

转载自jjchen-lian201205235512.iteye.com/blog/1629705
今日推荐