You can list of all directories, recursively from your working directory, using ag
in a chained command:
ag --null -g ./ | xargs -0 dirname | sort -u
--null
means each ag
output is separated by a \000
, which allows special characters to be handled by xargs
-g
means we only search in filenames, not inside the files themselves
./
running in the current working directory
| xargs -0
- pipe all the (relative) file paths from ag
into xargs
, which uses -0
to accept the --null
output we get from ag
dirname
returns just the directory name of each file
sort -u
we sort the directories returned and deduplicate them. We will have the same directory ones for every file it contains!
You can then pass the output of that list to grep
of something fancier, like [fzf][1]
.