Re: bash quandry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Attachment: pgpiNXYIlkE9D.pgp
Description: PGP signature


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux