Register
It is currently Mon Sep 22, 2014 10:15 am

select - basic tips on using bash's select command


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon May 16, 2005 11:35 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
Code:
echo " Please choose one of the following"
select thisisavarible in FUNCTION1 FUNCTION2  FUNCTION3 FUNCTION4 ;
do
$thisisavarible
done


This would create a menu

Code:
Please choose one of the following
1) FUNCTION1
2) FUNCTION2
3) FUNCTION3
4) FUNCTION4
#?


then choosing a number would run THAT function.


Top
 Profile WWW  
 PostPosted: Mon May 16, 2005 11:35 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
perhaps a better way is to also change the promt #?, called the PS3 prompt.

The new code might look something like this :

Code:
PS3='Please choose one of the following : '
select thisisavarible in FUNCTION1 FUNCTION2  FUNCTION3 FUNCTION4 ;
do
$thisisavarible
done


the resulting output now looks like this:

Code:
1) FUNCTION1
2) FUNCTION2
3) FUNCTION3
4) FUNCTION4
Please choose one of the following :



Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP