bash quandry

Todd Zullinger tmz at pobox.com
Wed Jun 20 04:19:15 UTC 2007


charles f. zeitler wrote:
> i'm having problems with getting a while loop to work.
> this script:
> 
> #!/bin/bash
> 
> 
> while [ 1 ] 
> do 
> done
> 
> when run, gives these error messages:
> 
> /home/fedora/0_scripts/done.ba: line 6: syntax error near unexpected token
> `done'
> /home/fedora/0_scripts/done.ba: line 6: `done'
> 
> at the command line,
> 
> while [ 1 ] ; do ; done
> 
> gives: bash: syntax error near unexpected token `;'

The syntax in the bash man page is:

while list; do list; done

You're missing 'list' after do.  You need to do something in the loop.
This works (not that it's useful):

while [ 1 ]; do echo "through the loop we go"; done

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erotic is when you use a feather, kinky is when you use the whole
chicken.
    -- C. Haynes.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 542 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20070620/153e1e32/attachment-0001.sig>


More information about the fedora-list mailing list