Linux find命令使用正則表達式


如果想要在find命令中使用正則表達式,需要指定正則表達式類型

-regextype type
    Changes the regular expression syntax understood by -regex and -iregex tests which occur  later  on  the command  line.   Currently-implemented  types  are  emacs (this is the default), posix-awk, posix-basic, posix-egrep and posix-extended.

-regex pattern
    File name matches regular expression pattern.  This is a match on the whole path,  not  a  search.   For example,  to match a file named `./fubar3', you can use the regular expression `.*bar.' or `.*b.*3', but not `f.*r3'.  The regular expressions understood by find are by default Emacs Regular  Expressions,  but this can be changed with the -regextype option.

example:

find /you/find/dir -regextype posix-extended -regex "regex"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM