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"
(3) How to match multiple keywords in GREP:
grep finds files with multiple numbers:
-R recursion,-E: Regular-L: Show only file names
- [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" $ "|grep-h dbsys.mxxxx.justwinit.cn"} ' |sh
Reference this site: http://justwinit.cn/post/714/
Linux find more than one specified type file at a time, specify a file or exclude a class of files