LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

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


Hi,
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:

Code:
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,
Morrolan
 
Old 07-17-2006, 08:42 AM   #2
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 17
Posts: 150

Rep: Reputation: 18
Yeah, you can use

Code:
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).
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:01 PM.

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