I'm trying to run my .sh file but when I try to execute it it doesn't work.
I did echo '#!/bin/bash' > cadetkpgm.sh
in order for the .sh file to be executable but when I use ./cadetkpgm.sh
or bash cadetkpgm.sh
to run the file t it doesn't work... any ideas?
Asked
Active
Viewed 160 times
-2

Olli
- 8,971

Kerven Cadet
- 13
- 1
1 Answers
1
#!/bin/bash
does not turn your shell script into an executable.
It only makes sure that it will be interpreted by bash
for which you give the location - once you have made it executable by chmod u+x SCRIPTNAME
.
Let me explain again: cadetkpgm.sh
is not a command, unless you have made it executable.

Klaus-Dieter Warzecha
- 2,750
-
im required to place that into the .sh file. when I try to run it it gives me this error: ./cadetkpgm2.sh: line 1: cadetkpgm2.sh: command not found. – Kerven Cadet Feb 25 '14 at 19:10
-
1
cadetkpgm2.sh
iscadetkpgm2.sh
. Check what's inside the file usingcat cadetkpgm2.sh
, because I think it's not what you think it is. After you fix the content of the file,bash cadetkpgm2.sh
will run it. You can make it executable withchmod u+x cadetkpgm2.sh
. – janos Feb 25 '14 at 19:09cadetkpgm.sh
orcadetkpgm2.sh
? – g_p Feb 25 '14 at 19:24echo '#!/bin/bash' > cadetkpgm.sh
would overwrite your file to just contain#!/bin/bash
– Dan Feb 25 '14 at 20:28