Http://blog.sina.com.cn/s/blog_62e7fe670101dg9d.html
Linux find a method that matches multiple keywords in GREP at a time by finding multiple specified files or excluding certain types of files
(1) Linux find more than one specified file at a time:
Find a.html and b.html
- find.-name "a.html"-name "b.html"
Find. -regex '. *\.txt\|. *\.doc\|. *\.mp3 '
- find.-regex '. *\.txt\|. *\.doc\|. *\.mp3 '
- ./a.txt
- ./a.doc
- ./a.mp3
(2) Exclude certain file types:
Exclude all files in the directory that end in HTML:
- find-type F!-name "*.html"
- find-type F!-name "*.html"
- ./ge.bak.02.09
- ./ge.html.changed.by.jack
- ./a.txt
- ./a.doc
- ./a.mp3
(3) Examples of excluding multiple file types:
- find . -type f ! -name "*.html" -type f ! -name "*.php" -type f ! -name "*.svn-base" -type f ! -name "*.js" -type f ! -name "*.gif" -type f ! -name "*.png" -type f ! -name "*.cpp" -type f ! -name "*.h" -type f ! -name "*.O" -type f ! -name "*.jpg" -type f ! -name "*.so" -type f ! -name "*.bak" -type f ! -name "*.log"    
< Span style= "LINE-HEIGHT:22PX; Font-family:verdana, Tahoma, Sans-serif; Background-color:rgb (252, 252, 250); " > (3) How to match multiple keywords in GREP:
grep finds files with multiple numbers:
-R recursion,-e: Regular -l: Displays only the file name
- [Email protected]:~/a# grep-r-E ' 0341028|100081|10086|10001 ' *
- a.txt:100081
- b.txt:10086
- c/cc.txt:0341028
- c/cc.txt:100081
- c/cc.txt:10086
- c/cc.txt:10001
- c.txt:10001
- d.txt:0341028
- grep-r-e-l ' 0341028|100081|10086|10001 ' *
- a.txt
- B.txt
- C/cc.txt
- C.txt
- D.txt
Examples of multiple types of files:
View Plainprint?
- find.-name "*.html" -o-name "*.js"|xargs grep-r "Busitree"
With awk:
View Plainprint?
- find . -name "*.php" |awk ' {print "cat " $0 " |grep -h dbsys.mxxxx.justwinit.cn"} ' |sh