Linux find command gotcha?

前端 未结 4 1378
再見小時候
再見小時候 2021-01-19 02:18

Hi I am trying to find all js & css files in one find command. I tried all of the below but in vain:

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

find WebContent         


        
相关标签:
4条回答
  • 2021-01-19 02:31

    Try this

    find WebContent -regextype posix-extended -regex '.*\.(css|js)$'
    
    0 讨论(0)
  • 2021-01-19 02:45

    use the -iname option case insensitive

    find WebContent \( -iname "*.js" -o -iname "*.css" \)
    
    0 讨论(0)
  • 2021-01-19 02:47

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

    find -name "*.js" -o -name "*.cpp"
    
    0 讨论(0)
  • 2021-01-19 02:50

    -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"
    
    0 讨论(0)
提交回复
热议问题