I'm trying to get a list of directories that are contained within a specific folder.
Given these example folders:
foo/bar/test
foo/bar/test/css
foo/bar/wp-content/plugins/XYZ
foo/bar/wp-content/plugins/XYZ/js
foo/bar/wp-content/plugins/XYZ/css
baz/wp-content/plugins/ABC
baz/wp-content/plugins/ABC/inc
baz/wp-content/plugins/ABC/inc/lib
baz/wp-content/plugins/DEF
bat/bar/foo/blog/wp-content/plugins/GHI
I'd like a command that will return:
XYZ
ABC
DEF
GHI
Essentially, I'm looking for the folders that are inside of wp-content/plugins/
Using find
has gotten me the closest, but I can't use -maxdepth
, because the folder is variably away from where I'm searching.
Running the following returns all of the child directories, recursively.
find -type d -path *wp-content/plugins/*
foo/bar/wp-content/plugins/XYZ
foo/bar/wp-content/plugins/XYZ/js
foo/bar/wp-content/plugins/XYZ/css
baz/wp-content/plugins/ABC
baz/wp-content/plugins/ABC/inc
baz/wp-content/plugins/ABC/inc/lib
baz/wp-content/plugins/DEF
bat/bar/foo/blog/wp-content/plugins/GHI