Linux如何搜索查找文件里面内容(3)

[oracle@DB-Server admin]$ grep -w "ORA" utlspadv.sql   --  ORA-XXXXX:        Monitoring already started. If for example you want   --  ORA-20111:   --  ORA-20112:   --  ORA-20113: 'no active monitoring job found'   --  ORA-20113: 'no active monitoring job found'   -- ORA-20111:   -- ORA-20112:   --  ORA-20100:   --  ORA-20113: 'no active monitoring job found'   --  ORA-20113: 'no active monitoring job found' [oracle@DB-Server admin]$ grep  "ORA" utlspadv.sql   --  ORA-XXXXX:        Monitoring already started. If for example you want   --  ORA-20111:   --  ORA-20112:   --  ORA-20113: 'no active monitoring job found'   --  ORA-20113: 'no active monitoring job found'   -- 0 |<PS> =>DBS2.REGRESS.RDBMS.DEV.US.ORACLE.COM 0 0 2 99.3% 0% 0.7% ""   -- |<PR> DBS1.REGRESS.RDBMS.DEV.US.ORACLE.COM=> 100% 0% 0% "" |<PR> ...   -- =>DBS2.REGRESS.RDBMS.DEV.US.ORACLE.COM 92 7 99.3% 0% 0.7% "" |<PR> ...   -- |<C> CAPTURE_USER1=>DBS2.REGRESS.RDBMS.DEV.US.ORACLE.COM 2 0 0 0.E+00   -- |<C> CAPTURE_USER1=>DBS2.REGRESS.RDBMS.DEV.US.ORACLE.COM   -- ORA-20111:   -- ORA-20112:   --  ORA-20100:   --  ORA-20113: 'no active monitoring job found'   --  ORA-20113: 'no active monitoring job found' [oracle@DB-Server admin]$

10: grep命令结合find命令搜索

[oracle@DB-Server admin]$ find . -name '*.sql' -exec grep -i 'v\$temp_space_header' {} \; -print create or replace view v_$temp_space_header as select * from v$temp_space_header; create or replace public synonym v$temp_space_header for v_$temp_space_header; create or replace view gv_$temp_space_header as select * from gv$temp_space_header; create or replace public synonym gv$temp_space_header             FROM gv$temp_space_header ./catspace.sql drop public synonym v$temp_space_header; drop public synonym gv$temp_space_header; ./catspacd.sql [oracle@DB-Server admin]$

11: egrep -w -R 'word1|word2' ~/klbtmp

12: vi命令其实也能搜索文件里面的内容,只不过没有grep命令功能那么方便、强大。

grep使用简明及正则表达式 

Linux下Shell编程——grep命令的基本运用

grep 命令详解及相关事例

Linux基础命令之grep详解

设置grep高亮显示匹配项

Linux grep命令学习与总结

14 个 grep 命令的例子

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/15034.html