while


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting while
# 1  
Old 08-08-2008
while

Hi,
I want to display a menu then I wrote :
Code:
while [1]
do
echo "                         Enter your choice"
done

But I receive :
Code:
myscript.sh[7]: [1]:  not found

Any idea ?
Thank you.
# 2  
Old 08-08-2008
drop the brackets...
i.e.

Code:
while 1

not

Code:
while [1]

# 3  
Old 08-08-2008
while [ 1 ];
do
echo " Enter your choice"
done

Pay attention to semicolon and spaces between the brackets
# 4  
Old 08-08-2008
Thank you.
But
Code:
while [ 1 ];
select menu_list in "choix 1"  "choix 2"  "fin"
do
	case $menu_list in
		"choix 1").... ;;
    		"choix 2")... ;;
		"fin") exit 0 ;;
		"") echo "$REPLY invalide option  "
	esac
done
done

And I get :
Code:
.sh[7]: syntax error at line 7 : `while' unmatched

# 5  
Old 08-08-2008
Code:
while [ 1 ]
do
     

done

"do" right after "while"

If somebody else has to maintain your code consider a more usual approach to
free while loops

Code:
while :
do

done 

# or
while true
do

done

# 6  
Old 08-08-2008
thanks to all.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question