开发者

Linux find command gotcha?

开发者 https://www.devze.com 2022-12-26 03:14 出处:网络
Hi I am trying to find all js & css fil开发者_开发问答es in one find command. I tried all of the below but in vain:

Hi I am trying to find all js & css fil开发者_开发问答es in one find command. I tried all of the below but in vain:

find WebContent -name "*.[jc]ss?"

find WebContent -name "*.[jc]ss{0,1}"

find WebContent -name "*.[jc][s]{1,2}$"

find WebContent -name "*.[jc]s{1,2}"

find WebContent -name "*.[jc]s[s]?"

Now what??


-name accepts arguments that are globs, not regular expressions. You could use -regex if you wanted to use regular expressions, but the -o option (meaning "or") is probably the simplest solution:

find WebContent -name "*.js" -o -name "*.css"


Try this

find WebContent -regextype posix-extended -regex '.*\.(css|js)$'


use the -iname option case insensitive

find WebContent \( -iname "*.js" -o -iname "*.css" \)


you can do boolean expressions with find. -o stands for OR.

find -name "*.js" -o -name "*.cpp"
0

精彩评论

暂无评论...
验证码 换一张
取 消