given the following structure:
.
├── a1
│ ├── q
│ ├── w
│ └── e
├── a2
│ ├── q
│ ├── e
│ └── s
I want a nested for-loop & find $ if-statement that has to work in the linux.
The expected output is the structures of sub-directory after checking if it contains a specific string in declared array.
I want something like this code:
declare -a folderlist=("a1", "a2")
declare -a checklist=("w", "s")
for folder in "${folderlist[@]}";
do
subfolders=$(ls ./$folder);
for subfolder in "${subfolders[@]}";
do
if [ $d == "w" -o $d == "s" ];
then echo ./$folder/$subfolder;
fi;
done;
done;
I wonder this part above:
do
if [ $d == "w" -o $d == "s" ];
then echo ./$folder/$subfolder;
fi;
done;
- How can I change [ $d == "w" -o $d == "s" ] part to something like if [ $d is in checklist ] ?
Expected Ouput:
./a1/w/
./a2/s/