How to Prompt the user to press Enter to Exit in terminal so that the terminal doesn't close automatically?
5,217
Add at the end of your script:
read junk
See Bash Manual for more info.
Related videos on Youtube
Author by
Belldandu
I don't answer questions unless i know the person making the question will benefit from my answer
Updated on September 18, 2022Comments
-
Belldandu almost 2 years
Here is my Port.sh file
echo 'Give me a maximum of 5 seconds to run please.' lsof -i | grep Xvnc | grep ESTABLISHED | grep $USER lsof -i | grep $USER | grep Xvnc | grep -o -P '(?<=:).*(?=->)' echo 'Brought to you by a cloudy and unlucky day.' echo 'Press enter to exit'
I would like to make the terminal wait for the user to press enter after the last echo before closing.
All of the users on my ubuntu desktop environment have the terminal set to close after the script is done.
Can anyone tell me what i can do to make the terminal wait for the user to press enter.
I have google searched and nothing relevant came up.
-
Belldandu over 9 yearsthats it? nothing else? if so then thanks and i kinda feel stupid x.x
-
Stephen Kitt over 9 yearsYou don't even need
junk
,read
on its own is sufficient. -
Belldandu over 9 yearsI thought it would be much harder than that x.x . This is what i get for thinking about it too hard.Thanks guys
-
madneon over 9 yearsFrom Bash manual: If no names are supplied, the line read is assigned to the variable REPLY.
-
Belldandu over 9 yearsthx @madneon i will be marking this as the answer in 3 minutes