shell编程之文件包含
shell脚本也可以包含文件
格式: . filename
或者source filename
举例:
a.sh
#!/bin/sh
calla()
{
echo "a.sh is called"
}
b.sh
#!/bin/sh
. ./a.sh
echo "exec b.sh
calla
chmod +x b.sh
./b.sh
>>> exec b.sh
>>> a.sh is called
shell脚本也可以包含文件
格式: . filename
或者source filename
举例:
a.sh
#!/bin/sh
calla()
{
echo "a.sh is called"
}
b.sh
#!/bin/sh
. ./a.sh
echo "exec b.sh
calla
chmod +x b.sh
./b.sh
>>> exec b.sh
>>> a.sh is called