조회 수 32179 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
echo -e "\033[COLOR1;COLOR2m sample text\033[0m"

[ TEXT ATTRIBUTES ]
  ANSI CODE           Meaning
        0          Normal Characters
        1          Bold Characters
        4          Underlined Characters
        5          Blinking Characters
        7          Reverse video Characters


[ COLORS ]
Bold offcolorBold oncolor
0;30Balck1;30Dark Gray
0;31Red1;31Dark Red
0;32Green1;32Dark Green
0;33Brown1;33Yellow
0;34Blue1;34Dark Blue
0;35Magenta1;35Dark Magenta
0;36Cyan1;30Dark Cyan
0;37Light Gray1;30White

ColorForegroundBackground
black3040
red3141
green3242
yellow3343
blue3444
magenta3545
cyan3646
white3747


$ echo -e '\E[47;34m'"\033[1mE\033[0m"
흰색배경에 파란색 글씨로 m이라고 출력됨


echo -e "\033[COLORm Sample text"

The "\033[" begins the escape sequence.You can also use "\e[" instead
of "\033[". COLOR specifies a foreground color, according to the table
above.The "m" terminates escape sequence, and text begins immediately
after that.

Note: With an echo, the -e option enables the escape sequences.You can
also use printf instead of echo.


printf "\e[COLORm sample text\n"

To print Green text

echo -e "\033[32m Hello World"
             or
printf "\e[32m Hello World"

정상으로 돌아오려면
echo -e "\033[0m"


[ Some examples ]
Block background and white text
echo -e "\033[40;37m Hello World\033[0m"


Reverse video text attribute option interchanges fg and bg colors.
Bellow statement prints block on white
echo -e "\033[40;37;7m Hello World\033[0m"
echo -e "\033[33;44m Yellow text on blue background\033[0m"
echo -e "\033[1;33;44m Bold yellow text on blue background\033[0m"
echo -e "\033[1;4;33;44mBold yellow underlined text on blue background\033[0m"


[ The "tput" command: ]
Other than echo there is a command called tput using which we
can control the way the output is displayed on the screen.But it is
less flexible than ANSI escape sequences.

[ SCRIPT SAMPLE ]
#!/bin/bash
# This script echoes colors and codes

echo -e "\n\033[4;31mLight Colors\033[0m  \t\t\033[1;4;31mDark Colors\033[0m"

echo -e "\e[0;30;47m Black    \e[0m 0;30m \t\e[1;30;40m Dark Gray  \e[0m 1;30m"
echo -e "\e[0;31;47m Red      \e[0m 0;31m \t\e[1;31;40m Dark Red   \e[0m 1;31m"
echo -e "\e[0;32;47m Green    \e[0m 0;32m \t\e[1;32;40m Dark Green \e[0m 1;32m"
echo -e "\e[0;33;47m Brown    \e[0m 0;33m \t\e[1;33;40m Yellow     \e[0m 1;33m"
echo -e "\e[0;34;47m Blue     \e[0m 0;34m \t\e[1;34;40m Dark Blue  \e[0m 1;34m"
echo -e "\e[0;35;47m Magenta  \e[0m 0;35m \t\e[1;35;40m DarkMagenta\e[0m 1;35m"
echo -e "\e[0;36;47m Cyan     \e[0m 0;36m \t\e[1;36;40m Dark Cyan  \e[0m 1;36m"
echo -e "\e[0;37;47m LightGray\e[0m 0;37m \t\e[1;37;40m White      \e[0m 1;37m"



[ANSI 문자]

DecabbrcmdechoNoteDecabbrcmdechoNoteDecabbrcmdechoNote
0NUL^@x

12FF^L

24CAN^X

1SOH^A

13CR^Mx줄바꿈25EM^Y

2STX^B

14SO^N

26SUB^Zx

3ETX^C

15SI^O

27ESC^[

4EOT^D

16DLE^P

28FS^\

5ENQ^E

17DC1^Q

29GS^]

6ACK^F

18DC2^R

30RS^^

7BEL^G소리

19DC3^S

31US^_

8BS^H지우기

20DC4^T

32SP공백공백공백
9HT^Ix21NAK^U

127DEL^?

10LF^Jx

22SYN^V

11VT^K

23ETB^W

x 사용할 수 없거나 Null 값으로 처리됨.
* ASCII Code 8 은 BackSpace 로 배치 파일에서 사용되면 의미 그대로 앞의 한 글자를 지웁니다.
* 명령 프롬프트의 Echo 출력 결과는 Color F0 으로 설정한 후 캡쳐한 것입니다.
TAG •

Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
401 개념 HLS(HTTP Live streaming) 2012.02.01 32881 0
400 C 거품정렬 Bubble Sort file 2005.08.10 32666 0
399 LINUX |(파이프), grep 명령어에 대해서 2006.02.06 32534 17
» LINUX [Shell Script] 글자 속성, 색깔 지정 2014.09.23 32179 0
397 개념 UDS (Unix Domain Socket) 2012.02.28 32149 0
396 일반 cmd.exe 명령 도움말 2005.08.31 31958 0
395 Pi 시프트 레지스터 사용방법 (Shift Register, 74HC595, 74HC165) 2016.11.21 31475 0
394 Android [GIT] git stash 사용하기 2012.10.22 31249 0
393 C 개선된 Trim() - trim(), trim_right(), trim_left() 2005.08.05 31118 0
392 MFC 레지스트리 쓰기, 읽기 함수 정리 2011.07.26 31110 0
391 Pi 라즈베리파이 3, Spec & PIN Map file 2017.02.06 30593 0
390 Android CPU사용률은 /proc/stat를 참고 2013.05.07 30550 0
389 Android Android Property 사용하기 2012.07.17 29712 0
388 LINUX [Shell Script] Shell 스크립트에서 매개변수 치환 2014.09.23 29687 0
387 일반 배치파일(bat)에서 날짜-시간을 파일 명으로 쓰기 2014.10.10 29268 0
목록
Board Pagination ‹ Prev 1 ... 3 4 5 6 7 8 9 10 11 12 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5