Bash – How to Prompt the user to press Enter to Exit in terminal so that the terminal doesn’t close automatically

bashcommand lineshell-scriptterminal

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.

Best Answer

Add at the end of your script:

read junk

See Bash Manual for more info.