Answer the question
In order to leave comments, you need to log in
How to implement list condition in bash?
There is a working script in Bash that iterates over directories in a loop and if the desired one does not exist inside these directories, then it creates it. But there is also a list of directories to be ignored. Everything works, but does not suit the long condition or. I tried to substitute in the cycle this way and that, but something does not work. Because it only compares the first value and ends up listing all the subdirectories along with the ones to be ignored.
Working version of the script.
function iterate() {
for entry in [email protected]; do
if ; then
if [ ! -d “$entry/content” ]; then
echo $entry
mkdir -p $entry/content/folderA
fi
fi
done
}
iterate /folder/*
iterate /folder/*/*
BLIST = "
*folder1*
*folder2*
*folder3*
*folder4*
"
function iterate() {
for entry in [email protected]; do
for BL in ${BLIST}; do
if ; then
if [ ! -d “$entry/content” ]; then
echo $entry
mkdir -p $entry/content/folderA
fi
fi
done
done
}
iterate /folder/*
iterate /folder/*/*
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question