Answer the question
In order to leave comments, you need to log in
How to run sh scripts in Linux?
It is necessary that the sh files be executed, "chmod +x script.sh" will not work, since you have to do it all the time, and this is the boss's computer ...
PS Linux distribution kit ALT (Russian mandriva)
Answer the question
In order to leave comments, you need to log in
You just need to realize that in Linux there are no file associations by extensions.
An extension for Linux is just a part of the file after the last dot, the system does not bind any actions to this.
Therefore, the only way to make .sh files executable is to set the executable flag on them via
Another option is to run bash itself, passing the file as an argument to it (because the bash binary is already executable).bash file.sh
in order not to constantly specify the interpreter in the terminal, you can make the script executable.
1. specify the interpreter in the script - specify the path to the bash interpreter after #!
it is like this by default.
you can check whereis bash
2. run the command to make it executable
3. after that you can run it just like./script.sh
And so
-----
$ cat ttt.sh
#!/bin/sh
echo "This is test"
$ ls -l ttt.sh
-rw-r--r-- 1 user user 32 May 17 16:26 ttt .sh
$ sh < ttt.sh
This is test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question