echo
| info | |
|---|---|
| name | echo |
| full name | echo |
| aliases | echo |
| tags | echo |
문자열을 표준 출력으로 내보내는 가장 기본적인 출력 명령이다. 대부분의 shell에서는 builtin으로 제공되며, 별도로 env echo 같은 형태로 GNU coreutils 구현을 직접 호출할 수도 있다.
Summary
echo [options…] STRING…- shell builtin이 우선 적용되는 경우가 많다.
- escape 해석이나 이식성이 중요하면
printf가 더 예측 가능하다.
Usage
echo [OPTION]... [STRING]...
echo [<switches>…] messageecho pattern: shell이 먼저 glob을 확장한 뒤 해당 경로/파일명을 출력
Options
-n: 마지막 개행 문자를 출력하지 않는다.-e: backslash escape를 해석한다. 예:\n,\t,\r-E: escape 해석을 비활성화한다. GNU coreutils 기본값이다.
Examples
echo hello world echo -n "no trailing newline" echo -e "line1\nline2" echo *.txt echo "$HOME"
echo *.txt: 현재 디렉터리의.txt파일명을 출력한다. 파일이 없을 때의 동작은 shell 옵션에 따라 달라진다.echo "$HOME": 변수 확장 결과를 출력한다.
Troubleshooting
echo는 shell builtin과 외부 명령(GNU coreutils) 사이에 동작 차이가 있을 수 있다. 옵션 처리와 escape 해석이 중요하면 printf를 우선 검토한다.
command -V echo로 현재 shell에서 builtin인지 확인할 수 있다.- Bash에서는 보통 builtin `echo`가 먼저 실행된다.
env echo –help처럼 호출하면 외부 `echo` 구현의 도움말을 직접 볼 수 있다.
Compatibility
- POSIX 환경에서는
-n과 escape 해석 동작이 shell마다 다를 수 있다. - GNU coreutils `echo`는
–help,–version,-E를 지원한다. - portable script에서는
echo -e대신printf가 더 안전하다.
Help
See Also
History
- codex:: 2026-06-20 Reorganized echo into the standard CLI reference structure with builtin/coreutils notes, options, examples, and help output.