Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use echo to output colors

Shulou Source: shulou.com Published: 2022-06-03 03:47:19 10月03日 Update

Grammar introduction:

Echo-e "\ e [31m input\ e [0m" # output is red

Example:

# Color: 30m echo-e "\ 033 [30m black word\ 033 [0m" echo-e "\ 033 [31m red word\ 033 [0m" echo-e "\ 033 [32m green word\ 033 [0m" echo-e "\ 033 [33m yellow word\ 0m" echo-e "\ 033 [34m blue word\ 033 [0m" echo-e "\ 033 [35m" echo-e "\ 033] Purple words\ 033 [0m "echo-e"\ 033 [36m sky blue words\ 033 [0m "echo-e"\ 033 [37m white words\ 033 [0m "# words background color range: 40 echo 47 echo-e"\ 033 [40 37m White character on Black background\ 033 [0m "echo-e"\ 033 [41X 37m White character on Red background\ 033 [0m "echo-e"\ 033] [42X 37m White character on Green background\ 033 [0m "echo-e"\ 033 [43it37m White character on Yellow background\ 033 [0m "echo-e"\ 033 [44trans37m "echo-e"\ 033 [0m "echo-e"\ 033] [45x 37m White character on Purple background\ 033 [0m "echo-e"\ 033] 37m White words on Blue background\ 033 [0m "echo-e"\ 033 [47cross 30m Black on White background\ 033 [0m "

Last control:

\ 33 [0m turn off all attributes\ 33 [1m set high brightness\ 33 [4m underline\ 33 [5m flicker\ 33 [7m reverse display\ 33 [8m blanking\ 33 [30m -\ 33 [37m set foreground color\ 33 [40m -\ 33 [47m set background color\ 33] [nA cursor up n line\ 33 [nB cursor down n line\ 33 [nC Move the cursor to the right on line\ 33 [nD cursor to the left on line\ 33 [y XH set cursor position\ 33 [2J clear screen\ 33 [K clear the content from the cursor to the end of the line\ 33 [s save cursor location\ 33 [u restore cursor position\ 33 [? 25l hide cursor\ 33 [? 25h display cursor above options can be used in combination!

Tags: Color cursor white word position content background output underline brightness attribute scenery white background example red range grammar black word black background control input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info Docker Huawei macOS