I wrote my own shell script, and I made it executable with chmod +x
command. But when I click to shell file and want to run it in terminal, it suddenly opens and then closes in a second. What is the problem?
Ubuntu – terminal closes when I run shell script
command linescripts
Best Answer
It also closes automatically once it has run your command.
Add
/bin/bash
at the end of your script to keep the terminal open.You can also add a
&& sleep 10
to keep the terminal open 10 seconds and see what's going on.Alternatively, add another line containing
read
at the end of the script to keep the terminal open until you press Enter.