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

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
6번째 줄: 6번째 줄:


==실습==
==실습==
<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
30번째 줄: 30번째 줄:
+ echo world
+ echo world
world
world
</source>
</syntaxhighlight>
:→ 수행하는 명령어를 보여준 후 실행함
:→ 수행하는 명령어를 보여준 후 실행함



2020년 11월 2일 (월) 02:40 판

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 }}