Linux控制台顏色__Linux

來源:互聯網
上載者:User

在 Linux 下若想輸出 類似與 Windows 下的多顏色字型如何做呢。本文就來介紹實現的方法。

首先,來看下 在Linux 下顏色的表示

All the colors that I have found are:
\033[30m - black
\033[31m - red
\033[32m - green
\033[33m - brown
\033[34m - blue
\033[35m - magenta
\033[36m - cyan
\033[37m - gray
\033[30m - dark gray
\033[31m - light red
\033[32m - light green
\033[33m - yellow
\033[34m - light blue
\033[35m - light magenta
\033[36m - light cyan
\033[37m - white

可以看出都是使用的轉義字型來實現的。這時就好辦了撒。

比如:

  Linux 終端輸入:echo -e  "\033[35;1m Shocking \033[0m"

  C代碼:                printf("\033[34mThis is blue.\033[0m\n");

是不是出錯不同的顏色了,記得最後要 "\033[0m"  關閉所有屬性,這樣又回到了系統預設的顏色了。


來自:http://blog.csdn.net/aegeaner/article/details/8650683

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.