P_n
P_n

Reputation: 992

How to make "select" display the options in a single column?

I have a random situation, when I use multiple choice menu in bash and add more items to my list selection, the menu does no longer stack up line by line

echo "         [?] What would you like to do:"
echo
# End

opt=""
select recon in Enumeration General Web-Recon Services Msfvenom Other
do
opt="$recon"
case $recon in 
Enumeration|General|Web-Recon|Services|Msfvenon|Other)   
        break
        ;;
*)
        echo # Spacer
        echo "You Sure? Try it again" 
        ;;
esac
echo $recon
done

What I get looks something like this:

         [?] What would you like to do:

1) Enumeration  3) Web-Recon    5) Msfvenom
2) General      4) Services     6) Other
#? 

However I'd rather prefer if it looked like this:

1) Enumeration
2) General  
3) Web-Recon
4) Services 
5) Msfvenom             
6) Other

Is there a way of telling the script to do so? Thank you

Upvotes: 9

Views: 4337

Answers (2)

Suhesh KS
Suhesh KS

Reputation: 1

You can check the following script and make addition based on the requirement,

#!/bin/bash
echo -n  "[?] What would you like to do : "
echo
echo

echo "1) Enumeration"
echo "2) General"
echo "3) Web-Recon"

echo
read entry
echo
case $entry in
    1)
        echo "Enumeration"  
        break
        ;;
    2)
        echo "General"
        break
        ;;
    3)
        echo "Web-Recon"
        break
        ;;
    default)
        echo "Default Action"
        break
        ;;
esac

Following is the output for this

[?] What would you like to do : 

1) Enumeration
2) General
3) Web-Recon

2

General

Upvotes: -1

Cyrus
Cyrus

Reputation: 88676

Use COLUMNS=0 before your select command.

Tested with bash 4.2.8.

Upvotes: 14

Related Questions