Recursively find all files that match a certain pattern

pw222

I need to find (or more specifically, count) all files that match this pattern:

*/foo/*.doc

Where the first wildcard asterisk includes a variable number of subdirectories.

rici

With gnu find you can use regex, which (unlike -name) match the entire path:

find . -regex '.*/foo/[^/]*.doc'

To just count the number of files:

find . -regex '.*/foo/[^/]*.doc' -printf '%i\n' | wc -l

(The %i format code causes find to print the inode number instead of the filename; unlike the filename, the inode number is guaranteed to not have characters like a newline, so counting is more reliable. Thanks to @tripleee for the suggestion.)

I don't know if that will work on OSX, though.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is there a way to remove all sessionStorage items with keys that match a certain pattern?

From Dev

Find all file names that match a pattern

From Dev

find certain files using glob pattern

From Dev

How to find all substrings that match a pattern in Rebol

From Dev

how to search for a line match from all files recursively found in a directory

From Dev

R: Regress all variables that match certain pattern

From Dev

Recursively find all php files not starting with a comment

From Dev

Find all executable files excluding certain directories

From Dev

Find all executable files excluding certain directories

From Dev

Count number of lines with a certain value in a column for all files in directory recursively

From Dev

Delete all files except in a certain subdirectory with find

From Dev

Deleting all files that do not match a certain pattern - Windows command line

From Dev

PHP - find all all files within directory that match certain string and put in array

From Dev

Bash pattern to match all files but directories

From Dev

Recursively find all files that match a certain pattern

From Dev

Find all files whose absolute path ends in a certain pattern

From Dev

Find files that match a certain size and modification time?

From Dev

Find files that match the regex pattern

From Dev

How to get all the files whose names contain certain pattern in the immediate subdirectory of the current directory without using find?

From Dev

Recursively find files ending with specified pattern

From Dev

Match all links with a certain pattern in javascript

From Dev

Delete all files from a folder using a bat that match a certain pattern in Windows 10

From Dev

Find recursively all files whose content match a specific regular expression

From Dev

Trying to find certain files recursively and change the filename

From Dev

recursively display all files with certain extension

From Dev

Find all strings which match the pattern

From Dev

How to find all the urls matching a certain pattern

From Dev

list all the files that dont match pattern in bash

From Dev

How to find all files that are not a certain extension?

Related Related

  1. 1

    Is there a way to remove all sessionStorage items with keys that match a certain pattern?

  2. 2

    Find all file names that match a pattern

  3. 3

    find certain files using glob pattern

  4. 4

    How to find all substrings that match a pattern in Rebol

  5. 5

    how to search for a line match from all files recursively found in a directory

  6. 6

    R: Regress all variables that match certain pattern

  7. 7

    Recursively find all php files not starting with a comment

  8. 8

    Find all executable files excluding certain directories

  9. 9

    Find all executable files excluding certain directories

  10. 10

    Count number of lines with a certain value in a column for all files in directory recursively

  11. 11

    Delete all files except in a certain subdirectory with find

  12. 12

    Deleting all files that do not match a certain pattern - Windows command line

  13. 13

    PHP - find all all files within directory that match certain string and put in array

  14. 14

    Bash pattern to match all files but directories

  15. 15

    Recursively find all files that match a certain pattern

  16. 16

    Find all files whose absolute path ends in a certain pattern

  17. 17

    Find files that match a certain size and modification time?

  18. 18

    Find files that match the regex pattern

  19. 19

    How to get all the files whose names contain certain pattern in the immediate subdirectory of the current directory without using find?

  20. 20

    Recursively find files ending with specified pattern

  21. 21

    Match all links with a certain pattern in javascript

  22. 22

    Delete all files from a folder using a bat that match a certain pattern in Windows 10

  23. 23

    Find recursively all files whose content match a specific regular expression

  24. 24

    Trying to find certain files recursively and change the filename

  25. 25

    recursively display all files with certain extension

  26. 26

    Find all strings which match the pattern

  27. 27

    How to find all the urls matching a certain pattern

  28. 28

    list all the files that dont match pattern in bash

  29. 29

    How to find all files that are not a certain extension?

HotTag

Archive