Where <xxx> can be any number and name of directories.
<yyy> can be another set of any number of names and directories.
I want to neglect [do not wish to allocated them to variables] all the <xxx> and <yyy> folders that do not have the the complete path uptil [logs] directory as shown above.
Assuming that you want to process these directories one-by one we can create a while loop and only have one environment variable set per directory process.
ls -1d /appl/user_projects/domains/*/servers/*/logs 2>/dev/null | while read dir
do
echo "${dir}"
dc=$(basename $(dirname "${dir}"))
echo $dc
domain=$(basename $(dirname $(dirname $(dirname "${dir}"))))
echo $domain
done
There are tidier ways of extracting the dc and domain name fields but it depends on what Shell you have.