"Bash 자식스크립트에서 변수 받아오기"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 4개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
{{소스헤더|parent.sh}}
{{소스헤더|parent.sh}}
<source lang='bash'>
<syntaxhighlight lang='bash'>
#!/bin/bash
#!/bin/bash
source child.sh
source child.sh
7번째 줄: 7번째 줄:
echo bar=[$bar]
echo bar=[$bar]
echo -- parent end...
echo -- parent end...
</source>
</syntaxhighlight>
{{소스헤더|child.sh}}
{{소스헤더|child.sh}}
<source lang='bash'>
<syntaxhighlight lang='bash'>
#!/bin/bash
#!/bin/bash
foo=hello
foo=hello
bar=world
bar=world
echo -- child end...
echo -- child end...
</source>
</syntaxhighlight>
{{소스헤더|실행결과}}
{{소스헤더|실행결과}}
<source lang='console'>
<syntaxhighlight lang='console'>
$ ./parent.sh  
$ ./parent.sh  
-- child end...
-- child end...
22번째 줄: 22번째 줄:
bar=[world]
bar=[world]
-- parent end...
-- parent end...
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[리눅스 source]]
* [[리눅스 source]]
* [[Bash 변수 다른 스크립트로 전달]]
* [[Bash 자식스크립트에 변수 전달하기]]
* [[Bash 자식스크립트에 변수 전달하기]]
* [[Bash 자식스크립트에서 변수 받아와서 다른 자식스크립트에 변수 전달하기]]


[[분류: Bash]]
[[분류: Bash]]

2020년 11월 27일 (금) 21:23 기준 최신판

1 개요[ | ]

parent.sh
#!/bin/bash
source child.sh
echo foo=[$foo]
echo bar=[$bar]
echo -- parent end...
child.sh
#!/bin/bash
foo=hello
bar=world
echo -- child end...
실행결과
$ ./parent.sh 
-- child end...
foo=[hello]
bar=[world]
-- parent end...

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}