Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-17-2006, 07:58 AM   #1
Registered: Sep 2003
Location: Manchester UK
Posts: 264

Rep: Reputation: 30
Simple bash problem: "until"

I have a simple bash problem - I have written a bash script which is actually a simple menu structure. I am using "until" loops for it, but I want to be able to press the key for the option and have it change menu, I don't want to have to press enter after every key.

This is what the structure looks like:

until [ "$utilities_selection" = "0" ]; do

echo "screen full of options"

read utilities_selection

case $utilities_selection in
	1 ) clear ; df ; press_enter ;;
	2 ) clear ; free ; press_enter ;;
	0 ) clear ; confirm_exit ;;
        * ) echo -n "Please enter a valid selection" ;
Is there something I can change about the first line that will enable me to not have to press enter after choosing a selection?

Thanks in advance,
Old 07-17-2006, 08:42 AM   #2
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 17
Posts: 150

Rep: Reputation: 18
Yeah, you can use

read -n 1 utilities_selection
That should automatically return after one character (which seems to be the length of your selection. If you get to double digits, you'll have to think up something else).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 10:43 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:16 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration