-1

I make some scripts to install programs automatic but is there a option to do the following.

Press Enter to continue or any other key to skip and go to the next thing? For example, the script will install keylock indicator and touchpad indicator but you want only the touchpad indicator.

Korkel
  • 1,158
  • 1
  • 10
  • 26
  • Something like this [How do I prompt for input in a Linux shell script](https://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script) ? – TuKsn May 26 '14 at 17:18
  • Yes, but that gives also a exit. That is what I not want. – Korkel May 26 '14 at 17:19
  • You can substitute `exit` with `break` if you don't want to leave the script completely. – TuKsn May 26 '14 at 17:19
  • 2
    This is really too broad to answer. Please include your actual script, the details will depend on what exactly you are doing. The classic approach is to prompt for user input using `read` and then use a `case` or `if/else` statement to react to whatever the user chose. – terdon May 26 '14 at 17:28
  • I don't have a script now to show, but I want it for later. :P – Korkel May 26 '14 at 17:30

2 Answers2

1

You can nicely resolve this problem using a menu with select-case statement. A working example can be found here:

How can I create a select menu in a shell script?

Federico Ponzi
  • 436
  • 4
  • 10
0

I guess you're using shell script?

read -p "Install XX? [yN] " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
    # do install
fi
kraxor
  • 5,459
  • 3
  • 26
  • 35