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.


Add at the end of your script:

read junk

See Bash Manual for more info.

  • 1
    thats it? nothing else? if so then thanks and i kinda feel stupid x.x – Belldandu Mar 20 '15 at 19:09
  • 3
    You don't even need junk, read on its own is sufficient. – Stephen Kitt Mar 20 '15 at 19:09
  • I thought it would be much harder than that x.x . This is what i get for thinking about it too hard.Thanks guys – Belldandu Mar 20 '15 at 19:12
  • 2
    From Bash manual: If no names are supplied, the line read is assigned to the variable REPLY. – madneon Mar 20 '15 at 19:17
  • thx @madneon i will be marking this as the answer in 3 minutes – Belldandu Mar 20 '15 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.