Orienting select choices vertically

From my script

#!/bin/bash
echo "Which of these does not belong in the group?"; \
        select choice in Mercedes Audi Chevrolet Audi Porsche BMW Volkswagen; do
if [[ $choice = Chevrolet ]]; then
        echo "Correct! Chevrolet is not a German marque."; break; fi
        echo "Errr...no. Try again."
 done

I'm getting a lateral listing of the choices:

1) Mercedes    3) Chevrolet   5) Porsche     7) Volkswagen
 2) Audi           4) Audi          6) BMW

I would like to get this:

1) Mercedes
2) Audi
3) Chevrolet
etc.
 

I have tried inserting \n and echo between the marques.

Ubuntu 18.04.2; Xfce 4.12.3; kernel 4.15.0-45-generic; bash 4.4.19(1); Dell Inspiron-518

select appears to take note of the LINES and COLUMNS variables set on terminal resize. Try adding

COLUMNS=0

into your code prior to the select statement.

Andrew

1 Like

I do not know how much it is correct. it works even like that

COLUMNS=100000

--- Post updated at 18:01 ---

I foresee your next question.
How to change prompt #?

PS3="which menu item we choose?"

The fastest way to invoke internal command help

help select
1 Like

Yes, either that or try my little introduction to select .

I hope this helps.

bakunin

5 Likes