I have a loop in my KornShell (ksh) script that I want to execute at least once, and I want an elegant way of doing it, however while I have found plenty of stuff on how to write a while loop, there does not seem to be anything for a do…while loop out there.
What I am doing is reading in a comma-delimited list of files from a configuration file and processing them. If the list of files is empty, then I want to process all files in the directory.
What is a good way to do this?
EDIT: Here is what I have currently. I grab the filename, then remove it from the string for the next pass. If the list of Files is empty, I quit the loop. BUT, if the list is empty to begin with, I want it to still run once.
while [[ -n "${FILES%%,*}" ]]; do
FILE="${FILES%%,*}"
FILES="${FILES#*,}"
done
you could fake it: