[SOLVED] bash while loop does not execute in succession?
SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I ran the following code, containing a while loop:
while [ $i -le 2009 ]
mkdir -p /local/directory/$i
ftp -n host port <<EOF
user username password
and I noticed something strange: when I checked the local directory about half an hour after the execution of the script had started, I noticed that the folders 1989, 1990, 1991, 1992 and 1999, 2000, 2001 existed. Nevertheless, some hours later when the script finished, the local directory contained all the folders it should, and it seems that everything is ok. But how is that possible? Isn't the bash loop executed in succession, I mean, I did not expect to see some years skipped at some point during the execution of the script, as was the case with the years from 1993 to 1998?
Any suggestions will be appreciated.
Are you sure that 1999,2000,2001 weren't left behind by a previous run of your while loop? mkdir is an atomic filesystem operation. There is no way that they should show up out of sequence.
Yes, I am sure that there were no left overs, as I either delete everything or nothing. But, as I come to think about it,
I fiddled with screen a bit, and it is possible that the later directories were created by an older process I had not terminated.
Thank You for your suggestion, for me it important to know that it is not possible for a while loop in bash to run out of succession.