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 (.) With a space in the middle of the file name or source filename
Instance
Create a two shell script file.
The test1.sh code is as follows:
#!/bin/bashurl= "Http://www.baidu.com"
The test2.sh code is as follows:
#!/bin/bash# use. To reference the test1.sh file. ./test1.sh# or use the following include file code # source./test1.shecho "URL: $url"
Next, we add executable permissions for test2.sh and execute:
$ chmod +x test2.sh $./test2.sh URL: http://www.baidu.com
Note: The included file test1.sh does not require executable permissions.
This article is from the "Wind Trace _ Snow Tiger" blog, please be sure to keep this source http://snowtiger.blog.51cto.com/12931578/1942042
SHELL--11, Shell files contain