[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Selecting from entries that would display more than one scre
From: |
Peng Yu |
Subject: |
[Help-bash] Selecting from entries that would display more than one screen |
Date: |
Thu, 22 Dec 2011 20:09:42 -0600 |
Hi,
I use the following code to print a number of items and then prompt to
select one item from them. When it needs more than one screen to
display all the items, it become a hassle to scroll back. I think that
there must be a better solution. For example, somehow a program figure
out how many items would be fit in the screen and wait for input. If
the user don't see anything, the user can go to the next screen. Does
anybody know a utility that will help me select an item from many
items.
local i=1;
for d in "$@";
do
echo "$i:$d";
let i++;
done;
echo "Enter a number between 1 and $#";
read choice;
while [ "$choice" -lt 1 ] || [ "$choice" -gt $# ]; do
echo "Enter a number between 1 and $#";
read choice;
done;
let choice--;
shift $choice;
$command "$1";
--
Regards,
Peng
- [Help-bash] Selecting from entries that would display more than one screen,
Peng Yu <=