Run a sh script
Solved
user
-
Un utilisateur novice -
Un utilisateur novice -
Hello.
Having been on Linux for a short while, I'm trying to create small bash scripts. However, I don't know how to execute them. Is there a specific command to run the script from a console?
Thank you in advance.
Having been on Linux for a short while, I'm trying to create small bash scripts. However, I don't know how to execute them. Is there a specific command to run the script from a console?
Thank you in advance.
1 réponse
Hello,
you mark it as executable:
Attention
Sourcing the file runs the execution IN THE CURRENT SHELL.
If there is an exit instruction, for example, you are ejected from the current shell.
Johan
Gates gave you the windows.
GNU gave us the whole house.(Alexandrine)
- either you specify the path to the command interpreter on the first line of your script
johand@horus:~/src/bash$ cat hello.sh #!/bin/sh echo ${USER} you mark it as executable:
johand@horus:~/src/bash$ chmod 744 hello.sh johand@horus:~/src/bash$ ./hello.sh johand
- or you run it directly with sh or bash (under Linux, sh is usually a link to bash)
sh hello.sh bash hello.sh
Attention
Sourcing the file runs the execution IN THE CURRENT SHELL.
If there is an exit instruction, for example, you are ejected from the current shell.
Johan
Gates gave you the windows.
GNU gave us the whole house.(Alexandrine)
user
Great, I understood, thank you!
ares
Thank you, I've been struggling for a long time to create a reinstallation script.