"리눅스 set -x"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 6개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;set -x
;set -x
* 디버그 용도로 자주 사용하는 옵션
* 실행되는 명령어와 인수들을 출력한다.
: Print commands and their arguments as they are executed.


==실습==
==실습==
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# cat a.sh
root@zetawiki:~# cat a.sh
echo hello
echo hello
echo world
echo world
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# sh a.sh
root@zetawiki:~# sh a.sh
hello
hello
world
world
</source>
</syntaxhighlight>
:→ 일반적인 수행 (명령어가 노출되지 않음)
:→ 일반적인 수행 (명령어가 노출되지 않음)


<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# cat b.sh
root@zetawiki:~# cat b.sh
set -x
set -x
echo hello
echo hello
echo world
echo world
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# sh b.sh
root@zetawiki:~# sh b.sh
+ echo hello
+ echo hello
27번째 줄: 30번째 줄:
+ echo world
+ echo world
world
world
</source>
</syntaxhighlight>
:→ 수행하는 명령어를 보여준 후 실행함
:→ 수행하는 명령어를 보여준 후 실행함


==같이 보기==
==같이 보기==
{{z컬럼3|
* [[리눅스 set]]
* [[리눅스 set]]
* [[리눅스 set -a]]
* [[리눅스 set -a]]
* [[리눅스 set -e]]
* [[리눅스 set -e]]
* [[리눅스 set -ax]]
* [[리눅스 set -euxo pipefail]]
* [[리눅스 bash/sh 디버깅 sh -x]]
* [[리눅스 bash/sh 디버깅 sh -x]]
}}


[[분류: Bash]]
[[분류: 리눅스 set]]

2022년 11월 7일 (월) 23:51 기준 최신판

1 개요[ | ]

set -x
  • 디버그 용도로 자주 사용하는 옵션
  • 실행되는 명령어와 인수들을 출력한다.
Print commands and their arguments as they are executed.

2 실습[ | ]

root@zetawiki:~# cat a.sh
echo hello
echo world
root@zetawiki:~# sh a.sh
hello
world
→ 일반적인 수행 (명령어가 노출되지 않음)
root@zetawiki:~# cat b.sh
set -x
echo hello
echo world
root@zetawiki:~# sh b.sh
+ echo hello
hello
+ echo world
world
→ 수행하는 명령어를 보여준 후 실행함

3 같이 보기[ | ]

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