find filenames NOT ending in specific extensions on Unix?

前端 未结 8 1564
悲&欢浪女
悲&欢浪女 2020-11-30 17:26

Is there a simple way to recursively find all files in a directory hierarchy, that do not end in a list of extensions? E.g. all files that are not *.dll or *.exe

相关标签:
8条回答
  • 2020-11-30 17:50
    find . ! \( -name "*.exe" -o -name "*.dll" \)
    
    0 讨论(0)
  • 2020-11-30 17:51

    one more :-)

    $ ls -ltr
    total 10
    -rw-r--r--    1 scripter     linuxdumb         47 Dec 23 14:46 test1
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:40 test4
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:40 test3
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:40 test2
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:41 file5
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:41 file4
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:41 file3
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:41 file2
    -rw-r--r--    1 scripter     linuxdumb          0 Jan  4 23:41 file1
    $ find . -type f ! -name "*1" ! -name "*2" -print
    ./test3
    ./test4
    ./file3
    ./file4
    ./file5
    $
    
    

    Unix find command reference

    0 讨论(0)
提交回复
热议问题