Issue
I notice when make a .sh file, usually, then we edit file's executable flag
$ chmod +x <sth>.sh
But without that executable flag, the .sh file can be executable.
$ sh ./<sth>.sh
why we need chmod?
Have a nice day!
Solution
By using chmod
and turning on execute permissions, you can just run the file using
<sth>.sh
Without executable permissions, if you have read permissions you can still run scripts but you must use an interpreter, such as sh
or bash
When you do
sh <sth>.sh
What this means is run the sh
command, which reads the .sh file, and then interprets it, therefore you don't need execute permissions.
Answered By - bkmoney Answer Checked By - David Marino (WPSolving Volunteer)