認證高級PHP講師
-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]的匹配行為,類似使用不同的方言來解析正則表達式。
經過我的實驗,我覺得這么寫
find . -regextype posix-extended -regex './autojump.(bash|zsh|sh)'
或者
find . -regextype posix-extended -regex './autojump.(ba|z)?sh'
./auto...
的./
是不能省略的,find
的正則匹配不能夠只匹配部分,要匹配完全(理解)。
==update==
如果前面的路徑很長,可以這樣子匹配
find . -regextype posix-extended -regex '.*autojump.(ba|z)?sh'
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號