I am writing a shell script that iterates through a set of IMAP folders.
Given:
WORKPATH=/var/mail/mydomain.com/myaccount/
I want to list all the subfolders inside.
Easy to find:
for SUB_FOLDER in $(find "$WORKPATH" -type d) do echo "SUB_FOLDER: $SUB_FOLDER" done
However: Some of these folders have a place in their name, for example:
/var/mail/mydomain.com/myaccount/.Deleted Mails/ /var/mail/mydomain.com/myaccount/.Junk Mails/
What to do on the code above to print something in the neighborhood:
SUB_FOLDER: /var/mail/mydomain.com/myaccount/.Deleted SUB_FOLDER: Mails/ SUB_FOLDER: /var/mail/mydomain.com/myaccount/.Junk SUB_FOLDER: Mails/
I tried using the -print0 and pipe option for xargs -0, but I had no luck. Playing with IFS has done even worse things for output than you need.
Could really use a hint, as make find makes only 2 tokens to increment a for 4 loop or an alternative way to iterate over a list.
source share