Ubuntu – Shell script does not run when I double click

15.04bashcommand linelubuntuscripts

I have made a shell script (test.sh) on my Lubuntu (15.04) desktop.
Permissions are: Only owner (View content + Change content + Execute).

When I double click test.sh, I choose "Execute in Terminal".
The Terminal (LXTerminal) opens, but the script is not executed.

When I type ./test.sh the script is executed. But that is not what I want.
Solution for this problem?

Best Answer

Sounds like your script lacks a shebang line. Make sure the very first line of the script reads:

#!/usr/bin/env bash

or

#!/bin/bash

On a side note, you should avoid putting .sh extension on a bash script, since bash is not sh. Preferably use no extension at all.

Related Question