3

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.

1 Answer 1

9

Add at the end of your script:

read junk

See Bash Manual for more info.

5
  • 1
    thats it? nothing else? if so then thanks and i kinda feel stupid x.x
    – Belldandu
    Mar 20, 2015 at 19:09
  • 4
    You don't even need junk, read on its own is sufficient. Mar 20, 2015 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, 2015 at 19:12
  • 2
    From Bash manual: If no names are supplied, the line read is assigned to the variable REPLY.
    – madneon
    Mar 20, 2015 at 19:17
  • thx @madneon i will be marking this as the answer in 3 minutes
    – Belldandu
    Mar 20, 2015 at 19:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .