The Shell file contains
Like other languages, the Shell can also contain external scripts. This makes it easy to encapsulate some common code as a standalone file.
The Shell file contains the following syntax format:
. FileName # Note number (.) There is a space in the middle of the file
Or
SOURCE filename
Instance
Create a two shell script file.
The test1.sh code is as follows:
#!/bin/bash# Author: Rookie Tutorial # Url:www.runoob.comurl="http://www.runoob.com"
The test2.sh code is as follows:
#!/bin/bash# Author: Rookie Tutorial # url:www.runoob.com# use the. Number to refer to the test1.sh file . /test1.sh# or use the following include file code # source. /" Novice Tutorial Official website address: $url"
Next, we add executable permissions for test2.sh and execute:
$ chmod +x test2.sh $. /test2.sh Novice Tutorial Official website address: http://www.runoob.com
Note: The included file test1.sh does not require executable permissions.
The Shell file contains