Quote:
Originally Posted by
hanson44
Your syntax works, so in a way it's "right". But I have never seen [ i=1 ] syntax. It really surprised me and made me scratch my head, and I don't understand exactly why it works.
The test/[ command treats a single non-empty string argument as true, and a single empty string argument as false.
i=1 is parsed as a single non-empty string.
For an infinite loop, I think it's best to use either
while :; do ... or
while true; do .... I believe it makes the intent clearer than testing something against itself.
apenkov:
With regard to the script, I hope this isn't something critical, because, as hanson44 points out, it is possible for entries to land in the wrong file. The batch processing suggestion is a much better idea.
Also, since it seems that the full script has not been posted, I can't say for certain what is going on, but, if the while-loop is spending most of its time checking for the start of a new hour, that's a job that is probably best handled by cron.
Regards,
Alister