I'm trying to parse subdirectory names, but the output breaks the names up into individual words.
Eg. If the subdirectory name is "Hello World", the output will be:
.
Hello
World
The following code works, but the output includes the current directory, which I don't want:
find "$my_dir" -maxdepth 1 -type d -print0 |
while IFS= read -rd '' dir;
do
echo "$dir";
done
I'm trying to include an if statement that eliminates the current directory from the output, but it seems the code still sees individual words for each subdirectory name:
find "$my_dir" -maxdepth 1 -type d -print0 |
while IFS= read -rd '' dir;
do
if ["$dir" != "."]; then
echo "$dir"
fi
done
shopt -s dotglob; dirs=( */ )will give you an array with all subdirectory names, so depending on what you want to do, that's an option.