Closed ghost closed 7 years ago
I'm not sure what you mean. The job of this package is to implement glob, and already handles recursive matching in subdirectories with */*/basename
.
If you instead wanted find examples -not -type d -path "*/patt*rn"
behavior instead, here's the implementation:
let l = String[], pat = Glob.FilenameMatch("*/patt*rn"), topdir = "examples"
foreach(walkdir(topdir)) do v
foreach(v[3]) do basename
path = joinpath(v[1], basename)
Sys.iswindows() && (path = replace(path, '\\', '/'))
ismatch(pat, path) && push!(l, path)
end
end
l
end
Note that you could make the ismatch
behavior more complex to implement any of the other flags of find
, such as by calling ismatch
on the basename
to implement -name
Thanks, find <path> -name <pattern>
is what I was looking for. Can it be made a part of Glob? Would be quite useful for people writing cross-platform code.
I'm using the following:
rglob(pat, topdir) = Base.Iterators.flatten(map(d -> glob(pat, d[1]), walkdir(topdir)))
Might be nice to have an overloaded method of walkdir
for a Glob
pattern, as discussed https://discourse.julialang.org/t/rdir-search-recursive-for-files-with-a-given-name-pattern/75605/12?u=stevengj
Is possible to add a flag to let glob look into subdirs recursively?