1. Use the editor to write a file, which is the command entered in the shell, can be used through the PATH environment variable reference to the command.
#! /bin/sh #! The following parameter is the program used to execute the script
#后面是注释
The rest is like writing in the shell.
Note that the last to add exit+ exit code, Shell 0 indicates success.
1 #! /bin/sh2#简单示例 3"hello,world"
2. Set the script to executable
There are two ways to execute a script
(1) Script name as parameters of shell
$/bin/sh Hello
(2) Change the mode of this file, add executable
chmod +x Hello
Note: The shell environment variable path is not set to look for commands in the current directory,
If there are two ways to make an error
1) plus the full path name./hello (recommended in this way)
2) Direct input Command PATH = $PATH:. Or this edit the. bash_profile file, add hello to the end of the file
(Note: The method of modifying the path variable may create a security issue)
Syntax for 3.shell
Not to be continued
Basic knowledge of Shell programming