first&second
2018-07-07 本文已影响0人
tmax
first:
#!/bin/bash
film="the first film"
echo "$film"
./second #创建子进程运行second,在子进程地址空间运行second
echo "$film"
second:
#!/bin/bash
echo "$film"
film="the second film"
echo "$film"
对first、second添加可执行权限后
执行
./first
结果
the first film
the second film
the first film
将first改成
#!/bin/bash
film="the first film"
echo "$film"
. ./second #父进程运行second,在父进程地址空间运行second
echo "$film"
执行
./first
结果
the first film
the first film
the second film
the second film
将first改成
#!/bin/bash
film="the first film"
echo "$film"
export film
./second #创建子进程运行second,在子进程地址空间运行second
echo "$film"
执行
./first
结果
the first film
the first film
the second film
the first film
将first改为
#!/bin/bash
film="the first film"
echo "$film"
#export film
film= `./second`
echo "$film"
将second改为
#!/bin/bash
#echo "$film"
film="the second film"
echo "$film"
执行
./first
结果
the first film
the second film #the second film被返回