LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 06-27-2021, 07:38 PM   #1
Snugbug
Member
 
Registered: May 2020
Posts: 97

Rep: Reputation: Disabled
Kubuntu 21.04 - How to tell bash "Press Enter to exit"?


I have a bash that executes some commands in the terminal and at the end of that bash, I want it to display a message saying "Press ENTER to exit..." (with no timeout, i.e. the bash should wait indefinitely for the ENTER key to be pressed). After the ENTER key has been pressed, I want the bash to exit and the terminal to close automatically.

I tried

Code:
#!/bin/bash

# some commands...

read -p "Press the ENTER key to exit ... " Enter
exit
but that doesn't work.

How can I make it work right, please?

Last edited by Snugbug; 07-02-2021 at 01:21 PM.
 
Old 06-27-2021, 08:16 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,698

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
https://ss64.com/bash/read.html
Code:
#!/bin/bash
read -n 1 -s -r -p "Press any key to continue"
echo
The easiest way is via an any key and the above waits for a single key press.
 
Old 06-27-2021, 09:13 PM   #3
Snugbug
Member
 
Registered: May 2020
Posts: 97

Original Poster
Rep: Reputation: Disabled
Thank you, I will try next time I'm running that system. Do you also know a solution especially for the ENTER key and for the bash to exit and close the terminal?

Last edited by Snugbug; 06-27-2021 at 09:14 PM.
 
  


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
[SOLVED] "Give root password for maintenance or press CTRL+D to continue" problem enter root password ag33k Slackware - ARM 9 01-12-2017 04:23 PM
[SOLVED] BASH - how to press ENTER carolflb Linux - Newbie 2 10-28-2009 01:03 PM
"Enter Key" not working, how to map "Enter Key" functionality to "F9" Key srinihi Linux - Newbie 1 04-03-2009 02:46 PM
"VFS: Insert root floppy and press ENTER", but no floppy RedShirt Linux - Software 7 02-05-2006 08:05 PM
"Disk boot failure. Enter system disk and press enter" Fear58 Linux - Hardware 3 06-25-2004 05:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 09: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