文件包含 导入文件
测试文件 test1.sh
#!/bin/bash
# author:菜鸟教程
# url:www.runoob.com
url="http://www.runoob.com"
测试文件 test2.sh
#!/bin/bash
# author:菜鸟教程
# url:www.runoob.com
#使用 . 号来引用test1.sh 文件
. ./test1.sh
# 或者使用以下包含文件代码
# source ./test1.sh
echo "菜鸟教程官网地址:$url"
$ chmod +x test2.sh
$ ./test2.sh
菜鸟教程官网地址:http://www.runoob.com
输入/输出 重定向
命令 | 说明 |
---|---|
command > file | 先清空文件中内容,将输出重定向到文件 |
command < file | 将输入重定向到文件 |
command >> file | 将输出以追加的形式重定向到file |
N > file | 将描述符为N的文件,重定向到文件file |
N >> file | 将描述符为N的文件,追加到file |
n>&m | 将输出文件m 和 n合并 |
n<&m | 将输入文件m 和 n合并 |
<<tag | 将开始标记为tag何结尾标记为tag 之间的内容作为输入 |