Two columns output in simple case menu?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Two columns output in simple case menu?
# 1  
Old 02-24-2012
Two columns output in simple case menu?

EDIT : System used : Any Linux distribution.

Hello everyone,

I m having quite a headache trying to figure out why I m having a 2 columns output in the following code :
 CHOIX1="Rotation 1"
 CHOIX2="Rotation 2"
 CHOIX3="Rotation 3"
 CHOIX4="Rotation 4"
 CHOIX5="Rotation 5"
 CHOIX6="Rotation 6"
 CHOIX7="Rotation 7"
 CHOIX8="Rotation 8"
 echo ============================
 echo "      Menu Rotation      "
 echo ============================
 PS3="Votre choix "
 select menu in "$CHOIX1" "$CHOIX2" "$CHOIX3" "$CHOIX4" "$CHOIX5" "$CHOIX6" "$CHOIX7" "$CHOIX8" "Back" "Quit"
         case $menu in
         "${CHOIX1}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX2}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX3}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX4}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX5}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX6}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX7}")    echo
         echo "Choix 1"
         break 1 ;;
         "${CHOIX8}")    echo
         echo "Choix 1"
         break 1 ;;
         "Back")       echo
         break 2 ;;
         "Quit")      echo
         exit ;;
         *)              echo
         echo "Mauvaise réponse"

Output shows like this :
Menu Rotation
1) Rotation 1 6) Rotation 6
2) Rotation 2 7) Rotation 7
3) Rotation 3 8) Rotation 8
4) Rotation 4 9) Back
5) Rotation 5 10) Quit
So it's technically working but the output is kinda ugly...

What I intended was having the following output line by line :

Menu Rotation
1) Rotation 1
2) Rotation 2
3) Rotation 3
4) Rotation 4
5) Rotation 5
6) Rotation 6
7) Rotation 7
8) Rotation 8
9) Back
10) Quit
Also, I m having a 3 columns output (3 columns of 3 lines) using the same code in an other function with different variables. Smilie

If anyone got any idea I d appreciate it !


Last edited by Sekullos; 02-24-2012 at 12:51 PM..
# 2  
Old 02-24-2012
My shell doesn't do that; not even the ksh I've got installed does that. This would seem to be shell and system specific.

So, what's your system? What's the version of your shell?
# 3  
Old 02-24-2012
Works on every Linux I ve been using so far.
Cent OS 6.0 and Linux xxx 2.6.9-42.ELhugemem
# 4  
Old 02-24-2012
Most linux doesn't even come with KSH at all.

Which version of KSH are you installing?
# 5  
Old 02-24-2012
@(#)PD KSH v5.2.14 99/07/13.2

# 6  
Old 02-24-2012
How strange, I have the exact same version you do. And i get the same behavior when running your code, but not mine.

However mine shows up much prettier:

      Menu Rotation
 1) Rotation 1                           6) Rotation 6
 2) Rotation 2                           7) Rotation 7
 3) Rotation 3                           8) Rotation 8
 4) Rotation 4                           9) Back
 5) Rotation 5                          10) Quit
Votre choix

---------- Post updated at 11:49 AM ---------- Previous update was at 11:49 AM ----------

Looking in man ksh I don't see any option to change select's behavior.
# 7  
Old 02-28-2012
Anyone else might have an idea for a better output using this menu?

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Special case to skip function in bash menu

In the bash menu below if the variant that is inputted is in the format NM_004004.3:c.274G>T the below works perfectly. My question is if the variant inputted isNM_004004.3:-c.274G>T or NM_004004.3:+c.274G>T then the code as is will throw an error due to a biological issue. Is it possible to to... (1 Reply)
Discussion started by: cmccabe
1 Replies

2. Shell Programming and Scripting

Menu and case statement scripting

hi all i am trying to get help with writing a script using case statement to display menu as 1) Authentication log 2) System log 3) Messages 4) Dmesg 5) Boot log Q) Exit When selecting the menu by 1 or 2 or 3 o 4 or 5, it should display the last 10 lines of the log files, if... (3 Replies)
Discussion started by: renegade11
3 Replies

3. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

4. Shell Programming and Scripting

Simple calculator with menu input - Need Help

I am trying to make a calculator. The user Enters number 1, chooses and operation, enters number 2, then chooses another operation or for the answer to be displayed. eg. 1 + 1 = or 1 + 1 + 2 + 1 = Both of these should be possible. #!/bin/bash read -p "what's the first number? " n1... (3 Replies)
Discussion started by: redshine6
3 Replies

5. UNIX for Dummies Questions & Answers

Simple bash script menu

Dear Sir, May I know how do I go about adding the following feature into the script below: When user enter values other than 1,2,3,4, a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed b) The screen is cleared again and the menu is displayed. #!/bin/bash clear var=1... (2 Replies)
Discussion started by: fusetrips
2 Replies

6. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

7. Shell Programming and Scripting

Perl simple text menu with options

Hopefully I'm in the right place. Im new to the forums and linux! I'm looking to add a menu to my perl hangman game i have created. The menu will use user input for the desired option and then perform the operation indicated. I would like something along the lines of: Welcome to Hangman... (1 Reply)
Discussion started by: jahburmski
1 Replies

8. UNIX for Dummies Questions & Answers

menu + awk + while + case

the idea is to create script with menu and when option 1 or2 is pressed program should clear screan display info and get back to menu.... I managed some code but getting errors... #!/bin/bash choice1=ls -l|awk'{print $9 $1}' choice2= ls | wc -c choice3=exit while do clear echo "... (8 Replies)
Discussion started by: me.
8 Replies

9. Shell Programming and Scripting

help with scripting a simple menu

Hi there. I'm trying to teach myself UNIX but the book I bought is a bit confusing. I'm trying out this exercise and I think I'm on the right track, but I'd appreciate any suggestions on how to improve what I have so far. Also, I'm not clear on how to use the read command to utilize the user's... (3 Replies)
Discussion started by: Jsmith
3 Replies

10. Shell Programming and Scripting

Simple Menu and coding

I am very new to Unix and don't know much about it. I've been trying to create a menu and what I don't understand is how to execute a command once a user makes a selection. I have the menu set up. In fact, the following is the code that I have thus far: #! /bin/csh # This is the UNIX menu... (0 Replies)
Discussion started by: sinjin
0 Replies
Login or Register to Ask a Question

Featured Tech Videos